how to calcualte t.

Started by
4 comments, last by Zakwayda 18 years, 11 months ago
a ray intersect a plane how to know if the ray reach the plane? if I know p0 and p1 of ray . get the equation: p0+ td=p1 d is direction ,but is not necessary unit vector p1-p0=td; then how to get t? I know cannot do this: t=(p1-p0)/d I must calculate length of the p1-p0 and d first?
Advertisement
Google is your friend.

Quote:
Subject 5.05: How do I find the intersection of a line and a plane?

If the plane is defined as:

a*x + b*y + c*z + d = 0

and the line is defined as:

x = x1 + (x2 - x1)*t = x1 + i*t
y = y1 + (y2 - y1)*t = y1 + j*t
z = z1 + (z2 - z1)*t = z1 + k*t

Then just substitute these into the plane equation. You end up
with:

t = - (a*x1 + b*y1 + c*z1 + d)/(a*i + b*j + c*k)

When the denominator is zero, the line is contained in the plane
if the numerator is also zero (the point at t=0 satisfies the
plane equation), otherwise the line is parallel to the plane.




I just need to know if the ray reach the plane.no the intersect point.

simple question :

give p1=p0+td; p1 p0 and t is known, how to get d?
Quote:Original post by derek7

I just need to know if the ray reach the plane.no the intersect point.

simple question :

give p1=p0+td; p1 p0 and t is known, how to get d?


Just rearrange the equation: d = (p1-p0)/t.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

sorry the question is
given p1=p0+td; p1 p0 and d is konwn, how to get t?

must calculate the ||p1-p0|| and ||d|| ?
Quote:sorry the question is
given p1=p0+td; p1 p0 and d is konwn, how to get t?

must calculate the ||p1-p0|| and ||d|| ?
I think I understand what you're asking. If so, the answer is:

t = dot(p1-p0, d)/dot(d, d)

If p1 is known to be on the ray, then dot(p1-p0, d) = |p1-p0|*|d|. The denominator dot(d, d) is |d|2. Divide through and you get |p1-p0|/|d|. So you are correct that it involves the lengths of those two vectors, but fortunately no square roots are required.

This topic is closed to new replies.

Advertisement