# how to calcualte t.

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

## Recommended Posts

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?

##### Share on other sites

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.

##### Share on other sites

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?

##### Share on other sites
Quote:
 Original post by derek7I 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.

##### Share on other sites
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|| ?

##### Share on other sites
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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634052
• Total Posts
3015262
×