开发者

Calculating which line is in front at the point where two line projections intersect

Two lines in 3d are projected onto 2d screen, and their projections intersect at a point which can be calculated.

If the endpoints of the lines in 3d space are known and their intersection point in the projection plane is also known, how can I determine which line is in front at this intersectio开发者_如何转开发n point?


As a naive solution, you can unproject the intersection point into 3D space as a segment(from zNear to zFar) and intersect this line with both of your test lines, taking the closer intersection.

edit: A bit more in-depth, you know your ray will intersect both lines when you form it so you can form a plane with the four points (two points for the projected segment and two points from the endpoints of your test line segment) and now your intersection test can be done in 2D using the standard parametric line equation.

This site has samples for line-line intersection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜