3D Line - Plane intersection?

守給你的承諾、 提交于 2020-01-22 03:00:45

问题


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 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)


回答1:


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.




回答2:


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 


来源:https://stackoverflow.com/questions/4382591/3d-line-plane-intersection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!