Advertisement

Line / Plane intersection

Started by December 09, 2001 03:10 AM
2 comments, last by djdynamic 23 years, 2 months ago
I desperately need someone to explain to me how I can find where a line and plane intersects (If I have the coordinates of the line, the normal of the plane, and a coordinate of the plane). It''s for my BSP Compiler. I''ve made posts on newsgroups and other things, and no one has been able to help me at all. Thanks.
d = -plane.normal.i * plane.coordinate.x - plane.normal.j * plane.coordinate.y - plane.normal.k * plane.coordinate.z;

a = ( -plane.normal.i * line.coordinate.x - plane.normal.j * line.coordinate.y - plane.normal.k * line.coordinate.z - d) / plane.normal.i * line.vector.i + plane.normal.j * line.vektor.j + plane.normal.k * line.vektor.k);

if (a < 0) NO_INTERSECTION;

intersection.x = line.coordinate.x + line.vector.i * a;
intersection.y = line.coordinate.y + line.vector.j * a;
intersection.z = line.coordinate.z + line.vector.k * a;
Advertisement
first before you calc intersection point on plane
you need to ensure, your line is really intersecting
with plane, you can do it that way, i''ve no time to
explain how to calculate exact intersection point on plane,
but it''s not tough job and very standard.

/*assumes precalculated plane''s D and normal*/

float distance1, distance2;
distance1 =distance2 =0;

distance1 = DOTPRODUCT (normal, line1)+D;
distance2 = DOTPRODUCT (normal, line2)+D;

if (distance1*distance2 >=0) { return 0; } /*no intersection occured*/
return 1;
/*yes*/
thanks for the posts... Im assuming with the anonymous poster, that ijk is xyz.....

This topic is closed to new replies.

Advertisement