Jump to content
  • Advertisement
Sign in to follow this  
VprMatrix89

Back to ray intersection

This topic is 3622 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 can't get the intersection to work. The D3D function I copied does work, but it only returns a bool true or false. I made a function for ray-plane intersection and to me it seems correct, and it probably is, but I would like someone to confirm this for me so I can single my problem. It goes like this.. *P is the output intersection. P0 is the ray orgin. V is the ray vector. N is the plane normal. P1 is a point on the plane. Used for getting d. void RAY_PLANE( POINT *P, POINT P0, VECTOR V, VECTOR N, POINT P1 ){ float d = bcDOT(&N,&P1); float Vd = bcDOT(&V,&N); float V0 = -1*(bcDOT(&P0,&N) + d) ; float t = V0 / Vd; P->x = (V.x * t)+P0.x; P->y = (V.y * t)+P0.y; P->z = (V.z * t)+P0.z; } Does this seem right?

Share this post


Link to post
Share on other sites
Advertisement
I think "float V0 = -1*(bcDOT(&P0,&N) + d);" should be "float V0 = d - bcDOT(&P0,&N);". Or just change "float d = bcDOT(&N,&P1);" to "float d = -bcDOT(&N,&P1);"

My code for Ray-Plane-Intersection is:

t = (dist - dot(n,p))/dot(n,d);
intersection = p+d*t;

where:
dist = distance from origin to plane (n dot point on plane)
n = normal of plane
p = ray position
d = ray direction

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!