计算两条线投影相交点处的哪条线在前面
3d 中的两条线投影到 2d 屏幕上,它们的投影相交于可以计算的点。
如果 3d 空间中线的端点已知并且它们在投影平面中的交点也已知,那么如何确定该交点处哪条线在前面?
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 intersection point?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为一个简单的解决方案,您可以将交点作为一段(从 zNear 到 zFar)取消投影到 3D 空间中,并将这条线与两条测试线相交,采用更近的交点。
编辑:更深入一点,您知道光线在形成光线时会与两条线相交,因此您可以用四个点形成一个平面(两个点用于投影线段,两个点来自测试线段的端点)现在您可以使用标准参数线方程以二维方式完成相交测试。
此站点有直线相交的示例。
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.