查找两个3D线段的相交点的算法 [英] The Algorithm to Find the Point of Intersection of Two 3D Line Segment

查看:401
本文介绍了查找两个3D线段的相交点的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

找到两个2D线段的交点很容易; 公式很简单.但是恐怕找不到两个3D线段的交点.

Finding the point of intersection for two 2D line segment is easy; the formula is straight forward. But finding the point of intersection for two 3D line segment is not, I afraid.

在C#中最好的算法是找到两个3D线段的交点?

What is the algorithm, in C# preferably that finds the point of intersection of two 3D line segments?

我在此处找到 C ++实现.但是我不信任该解决方案,因为它偏向某个平面(请看实现部分下的perp的实现方式,它假定对z plane的偏爱.任何通用算法都不得假定任何平面方向或偏好).

I found a C++ implementation here. But I don't trust the solution because it makes preference of a certain plane ( look at the way perp is implemented under the implementation section, it assumes a preference for z plane. Any generic algorithm must not assume any plane orientation or preference).

有更好的解决方案吗?

推荐答案

我找到了一个解决方案:

I found a solution: it's here.

这个想法是利用向量代数,在这个阶段之前使用dotcross来简单地解决问题:

The idea is to make use of vector algebra, to use the dot and cross to simply the question until this stage:

a (V1 X V2) = (P2 - P1) X V2

并计算a.

请注意,此实现不需要任何平面或轴作为参考.

Note that this implementation doesn't need to have any planes or axis as reference.

这篇关于查找两个3D线段的相交点的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆