Plane intersect
If I have a point in space and a normal with that, how can I calculate where on a plane (what point in space) it would hit if that vector was of infinite length?
plane equation :
ax+by+cz+d = 0
line equation:
x = x0 + t*dx;
y = y0 + t*dy;
z = z0 + t*dz;
substitute, solve for t, you''re all set.
ax+by+cz+d = 0
line equation:
x = x0 + t*dx;
y = y0 + t*dy;
z = z0 + t*dz;
substitute, solve for t, you''re all set.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Thanks, just to make sure
dx, dy, dz = the normal
x0, y0, z0 = the starting point
That resulted in the following equation:
[a*(x0+t*dx)] + [b*(y0+t*dy)] + [c*(z0+t*dz)] + d = 0
To solve t I got two passed two values of t into the equation, using these to calculate the k value of a linear equation.
(y = kx + m)
f(t) = [a*(x0+t*dx)] + [b*(y0+t*dy)] + [c*(z0+t*dz)]
y1 = f(0)
y2 = f(1)
k = y2 - y1
m = f(0)
t = (0 - m) / k
Then passed t back into the given line equation...
This seems like the long way around? Is there an easier way?
[edited by - JohanK on March 26, 2002 3:56:36 AM]
[edited by - JohanK on March 26, 2002 6:06:05 AM]
dx, dy, dz = the normal
x0, y0, z0 = the starting point
That resulted in the following equation:
[a*(x0+t*dx)] + [b*(y0+t*dy)] + [c*(z0+t*dz)] + d = 0
To solve t I got two passed two values of t into the equation, using these to calculate the k value of a linear equation.
(y = kx + m)
f(t) = [a*(x0+t*dx)] + [b*(y0+t*dy)] + [c*(z0+t*dz)]
y1 = f(0)
y2 = f(1)
k = y2 - y1
m = f(0)
t = (0 - m) / k
Then passed t back into the given line equation...
This seems like the long way around? Is there an easier way?
[edited by - JohanK on March 26, 2002 3:56:36 AM]
[edited by - JohanK on March 26, 2002 6:06:05 AM]
[a*(x0+t*dx)] + [b*(y0+t*dy)] + [c*(z0+t*dz)] + d = 0
Factor t out of the expression :
t*(a*dx+b*dy+c*dz)+(a*x0+b*y0+c*z0+d)=0
Factor t out of the expression :
t*(a*dx+b*dy+c*dz)+(a*x0+b*y0+c*z0+d)=0
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement