Jump to content
  • Advertisement

Archived

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

noname100

Finding where a plane and a line intersect

This topic is 5253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I find the point where a line and a plane intersect. Assume that ax+by+cz+d=0 (the standard form for a plane) And I have two points (e,f,g) and (h,i,j). Is there a formula to figure out the point of intersection? For those who are wondering, I''m trying to build my own 3D engine at the moment, so this is basically a major part of it. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Pretty easy,

equation of a plane : ax+by+cz+d=0 or N.(P-P0) = 0
equation of a line : P(t) = Q + tV


sub eq of a line into the eq for a plane

N.(Q + tV -P0) = 0

solve for t

t = (N.P0 - N.Q)/N.V

sub t back into the equation of a line, and you have the point of intersection.

Hope that helps

Share this post


Link to post
Share on other sites
I''m not that far up the math ladder, so help me out a little here. I''m assuming in the line equation, Q and V are two points and t is the slope?

But I''m sorta confused on the plane equation. What does N.(P-PO) mean?

And example would be great if you could do one.

Share this post


Link to post
Share on other sites
Q is the ''origin'' of the line (e,f,g)
V is the direction of the line (h,i,j) - (e,f,g)
t is a number ranging from 0 to 1 (you can think of it as time)

so at t = 1
P(1) = (e,f,g) + (h,i,j) - (e,f,g) = (h,i,j)


at t = 0
P(0) = (e,f,g)

The values inbetween are points on the line connecting (e,f,g) and (h,i,j)

N.(P-PO) = 0 is another way of writing ax+by+cz+d=0
N.P - N.P0 = 0 or Nx*Px + Ny*Py + Nz*Pz - N.P0 = 0
which can be written as x*a + y*b + z*c + d = 0




Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Terminology: That was the parametric equation of a line.

Share this post


Link to post
Share on other sites
Ok, im understanding how to do it in general. But I''m not really understanding the N.(P-P0) = 0 part. Or really just what the . (dot) means and the N, P, and P0.

So if possible, could you expand both the

t = (N.P0 - N.Q)/N.V

formula and

N.(P-P0) = 0

formula. What I''m really confused about it the P0 part. Is that the origin of the line at P(0) or something completely different?

Thanks again.

Share this post


Link to post
Share on other sites
N.(P-P0) = 0

the . means the dot product. P0 and P are two points that lie on the plane, and N is the normal vector of the plane. To understand the equation you really need to understand the dot product (im sure google can help you with that).

The most important thing to know is that the dot product of two perpendicular vectors is 0. Since P and P0 are two points on the plane, P-P0 is a vector that is perpendicular to the planes normal vector N. And since the dot product of 2 perpendicular vectors is 0, we can write

N.(P-P0) = 0

The dot product can also be written in terms of the components of the vector as

A.B = Ax*Bx + Ay*By + Az*Bz

And so you can evaluate N.(P-P0) = 0
to be Nx*Px + Ny*Py + Nz*Pz - N.P0 = 0
-N.P0 is a constant(P0 is always going to be a point on the plane and the normal vector is always going to be the same), and so it is sometimes just written as the letter D.

So Nx*Px + Ny*Py + Nz*Pz - N.P0 = 0
becomes Nx*Px + Ny*Py + Nz*Pz + D = 0 with D = -N.P0

Now, applying that to t = (N.P0 - N.Q)/N.V we get

t = -1* (Nx*e + Ny*f + Nz*g + D)/(Nx*(h-e) + Ny*(i-f) + Nz*(j-g))

(here i took a minus one out of (N.P0 - N.Q) to make it -(N.Q -N.P0), or -(N.Q + D), and then evaluated the dot product N.Q)

if you then multiply the denominator by the -1, you get

t = (Nx*e + Ny*f + Nz*g + D)/(Nx*(e-h) + Ny*(f-i) + Nz*(g-j))

Hope that clears it up

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!