Skip to main content
GameDev.net gamedev.net
🔒 Locked

is this correct?

Started by speciesUnknown Jun 14, 2007 at 3:37 AM 2 replies 650+ views
Original Post
speciesUnknown
speciesUnknown
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) ?
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
d00fus
d00fus
Do you mean the point of intersection of the ray and the plane? That will be given by Rs + t * Rd.
speciesUnknown
speciesUnknown
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);
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
speciesUnknown
speciesUnknown
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.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.