Intersection between a line and a plane..

Started by
4 comments, last by monkeyman 23 years, 10 months ago
If anybody can help me with this I would greatly appreciate it.. I need to find the intersection between a line and and a plane for polygon splitting purposes..the way I do it now is: *Find the distance from the first point to the plane.. *Find the distance from the second point to to the plane.. *Get a percentage from the 2 distances.. *Add the vector of the line multiplied by this percentage to the first point. At right angles this works beautifully, but the closer the line gets to being parallel with the plane, floating point imprecision renders the distances(which I use for my percentage) more and more inaccurate..in most cases it''s not too obvious, but I know there must be a better way..does anybody know the definitive FDA approved formula for finding the intersection between a line and a plane? "Like all good things, it starts with a monkey.."
"Like all good things, it starts with a monkey.."
Advertisement
Go here : http://www.swin.edu.au/astronomy/pbourke/geometry/planeline/

Nate Miller
http://nate.scuzzy.net
To add to that,

You want to use the SECOND solution given on that page (using the plane equ Ax + By + Cz + D). Remember that A, B, and C are the plane''s normal. You can solve for D by plugging in one point in the plane (one vertex), and solving for D.

You can think of a line (or ray) as a point and a direction. So let p represent your starting point, and v be your direction.

Any point on the line can be described as:

p + uv, where u is a scalar (EX: At u = 0, we get p (start point). At u = 1, we get one step along the line in the direction of v).

Now you can use the equ as given on the page:
A(p.x + u*v.x) + B(p.y + u*v.y) + C(p.z + u*v.z) + D = 0.

You''ve got A, B, C, D, p.x, p.y, p.z, v.x, v.y, and v.z, so just solve for u now!

If u comes out to be positive, then the ray intersects the plane at point p + uv. But now you''ll have to see if it intersects the polygon contained in that plane, which is another set of equations...

Vyvyvan
I think I can dig the concept so far, but I need to clarify..if I have this right:

*A, B, and C are the xyz normal vector values of the plane

*D will be the negative value of (Ax + By + Cz)

*p.x, p.y, and p.z represent a point on the plane

*v.x, v.y, and v.z represent the vector from the 2 endpoints of the line

*the u value is the percentage of the line vector that must be added to the first point to the find the intersection..I think this is the same value that I''ve been calculating from the distances, but far more accurate..

Provided all that is correct, I have another small stumbling block..I didn''t pay as much attention in algebra class as I should have(I never got off on math until I started programming) and I''m unsure about how to solve for u with the equation

A(p.x + u*v.x) + B(p.y + u*v.y) + C(p.z + u*v.z) + D = 0

I appreciate your patience and help..I''m really good with mathematical concepts but lack some essentials..I am, after all, the monkeyman..

"Like all good things, it starts with a monkey.."
"Like all good things, it starts with a monkey.."
Got it now, thanks for all the help

"Like all good things, it starts with a monkey.."
"Like all good things, it starts with a monkey.."
Good! Hope it helped. I remember having one HELL of a time with that same problem on my graphics final. If you need any more help with it, let me know.

Vyvyan

This topic is closed to new replies.

Advertisement