I am having two Vectors (X,Y,Z), one above Y=0
and one below Y=0
.
I want to find the Vector (X,Y,Z) where the line between the two original vectors intersects with the Y=0
level.
How do I do that?
Example Point A:
X = -43.54235
Y = 95.2679138
Z = -98.2120361
Example Point B:
X = -43.54235
Y = 97.23531
Z = -96.24464
These points read from two UnProjections from a users click开发者_如何学Python and I'm trying to target the unprojection to Y=0
.
(I found 3D line plane intersection, with simple plane but didn't understand the accepted answer as it's for 2D)
I suspect that by two vectors, you really mean two points, and want to intersect the line connecting those two points with the plane defined by Y=0
.
If that's the case, then you could use the definition of a line between two points:
<A + (D - A)*u, B + (E - B)*u, C + (F - C)*u>
Where <A,B,C>
is one of your points and <D,E,F>
is the other point. u
is an undefined scalar that is used to calculate the points along this line.
Since you're intersecting this line with the plane Y=0
, you simply need to find the point on the line where the "Y" segment is 0.
Specifically, solve for u
in B + (E - B)*u = 0
, and then feed that back into the original line equation to find the X and Z components.
The equation for the line is
(x–x1)/(x2–x1) = (y–y1)/(y2–y1) = (z–z1)/(z2–z1)
So making y=0 yields your coordinates for the intersection.
x = -y1 * (x2-x1)/(y2-y1) + x1
and
z = -y1 * (z2-z1) /(y2-y1) + z1
精彩评论