Is there any quick way to find the intersection point between Plane and Ray?

  • \$\begingroup\$ Try googling "line plane intersection" \$\endgroup\$ – brandon Feb 1 '12 at 14:27
  • 1
    \$\begingroup\$ An intersection between a Vector3 and a Plane doesn't make sense. You can find the intersection between a Plane and a line segment, a ray, or a line, but all of these require not one, but two Vector3's to be represented. Or you can check if a certain Point lies on the Plane or not. Which of these are you trying to achieve? \$\endgroup\$ – David Gouveia Feb 1 '12 at 14:30
  • \$\begingroup\$ i am using the Vector3 as a Direction , Mmm it should be a Ray not a Vector3 \$\endgroup\$ – MhdSyrwan Feb 1 '12 at 14:38
  • 2
    \$\begingroup\$ realtimerendering.com/intersections.html \$\endgroup\$ – Tili Feb 1 '12 at 14:44
  • \$\begingroup\$ long story short, study linear algebra \$\endgroup\$ – brandon Feb 1 '12 at 14:51

Try the following method which relies on XNA's built in Math API to intersect a Ray and a Plane and get back the point of intersection:

Vector3? GetRayPlaneIntersectionPoint(Ray ray, Plane plane)
    float? distance = ray.Intersects(plane);
    return distance.HasValue ? ray.Position + ray.Direction * distance.Value : null;

The method returns null if there's no intersection, or the point of intersection otherwise.

  • \$\begingroup\$ thanks very much :) , i thought it returns just a boolean \$\endgroup\$ – MhdSyrwan Feb 1 '12 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.