If the manipulation task information is available at the time of planning, such as forces and torques that a grasp should apply onto the object, grasps more suitable for the task can be found. In this paper, we propose a ray-shooting based algorithm, which computes the quality of a grasp for performing given forces and torques. The method can deal with both force-closure grasps and non force-closure grasp. In case of multiple forces and torques, task wrench space is built. The quality is measured as the scale that the task wrench space fit into the grasp wrench space. Numerical experiments show the the feasibility of our method.