Jump to content
  • Advertisement
Sign in to follow this  
rfterdarc

ray plane intersection

This topic is 4898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have a plane at 0, 0, 0 and a ray at origin -20, 10, -10 and the direction of the ray is 30deg right, 20deg down how do i calculate where it intersects the plane ?

Share this post


Link to post
Share on other sites
Advertisement
The ray equation is

R(t) = O + tD

where O is the ray starting point, D is the (normalized) ray direction vector, and t is a parameter that gives you a point ( R(t) ) on the ray

The plane equation is

ax + by + cz + d = 0

wich can be rewritten as

N.P + d = 0

where N is the plane normal, P is a point on the plane and d is the distance of the plane from the origin. ( . means dot product )

So to find the intersection between the two you have to get the ray and plane equations. The ray origin is ( -20, 10, -10 ), you must find the direction vector and normalize it (what do you mean by 30 degrees right, 20 degrees down?)

Then you find the plane equation. Again, what do you mean? That the plane normal is ( 0, 0, 0 )? You need the distance from the origin too.

Then you compute the intersection. You have to replace the 'P' in the plane equation with the ray equation. So it becomes

N.( O + tD ) + d = 0

N.O + t( N.D ) + d = 0

t = -( N.O + d ) / ( N.D )

The final equation is the one you need. Compute the value of the parameter t, then substitute it in the ray equation to get the actual point:

Point = O + tD

Share this post


Link to post
Share on other sites
thanks for the good answer

would you be able to give some example values in the equations please, would help alot

:)

Share this post


Link to post
Share on other sites
distance = ( plane_normal dot ( plane_origin - ray_origin ) ) / ( plane_normal dot ray_direction )

location = ray_origin + ( ray_direction * distance )

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!