# 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.

## 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 on other sites
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

1. 1
2. 2
Rutin
21
3. 3
JoeJ
18
4. 4
5. 5

• 14
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631722
• Total Posts
3001892
×