Jump to content
  • Advertisement
Sign in to follow this  
speciesUnknown

is this correct?

This topic is 4053 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

In the context of a ray colliding with a plane: I know that this is mathematically correct: Pn = plane normal Po = plane origin (any point of the plane works but the origin is calculated already Rs = ray start Rd = ray direction t=(Pn.(Po - Rs)) / (Pn.Rd); but is this correct: vector at collision point = ray_start +(ray_normal * t) ?

Share this post


Link to post
Share on other sites
Advertisement
Do you mean the point of intersection of the ray and the plane? That will be given by Rs + t * Rd.

Share this post


Link to post
Share on other sites
should rd be normalised?

my problem is as described in this thread:

http://www.gamedev.net/community/forums/topic.asp?topic_id=451622

but i didnt get any answers, possibly because my question was too esoteric, so i have simplified it here. Im getting some wierd results with the exact formulae that i have stated above, such as the contact point being behind the start of the ray, or the contact point being on the ray, but slightly above the surface:

/
1
/
-------====2=====--------
/
/
/
/




--- is the plane
=== is the visible polygon on that plane

/
/ is the ray

1 is where the intersection is being calculated.
2 is where it should theoretically be.

I get different, but always wrong, results depending on what i do, and right now im getting the intersection point behind the start of the ray.

im calculating the plane from a triangle in 3-space

my formulae are as follows:

plane equation:
v1, v2, v3 = vertices of the triangle

origin=v1
d=cross_product(v1-v2,v1-v3)

intersection point:
t=distance along ray
Pn = plane normal
Po = plane origin (any point of the plane works but the origin is calculated already
Rs = ray start
Rd = ray direction
t=(Pn.(Po - Rs)) / (Pn.Rd);

intersection point:
contact_point = r->start +(r->direction*t);

Share this post


Link to post
Share on other sites
No problem, I fixed it myself.
I wasnt calculating the plane origin, so it was defaulting to 0.
I realised this when i decided to exaustatively visualise every piece of information in the test, and saw that the plane origin didnt touch the plane.

Thats why the intersection point was always a constant (and wrong) distance from the plane.
Any way, thanks d00fus for confirming that my formulae were correct, thus narrowing down my search.

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!