Archived

This topic is now archived and is closed to further replies.

djdynamic

Line / Plane intersection

Recommended Posts

djdynamic    122
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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;

Share this post


Link to post
Share on other sites
rickpeek    122
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*/

Share this post


Link to post
Share on other sites