3D线交会算法 [英] 3D lines intersection algorithm

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

问题描述

I,采用具有线方向的x,y和z

I have line direction using x,y,z

和两分A,B,我用用B-A线段

and two points A, B , I used line segment using B- A

如何让他们之间的交点

最好的问候

推荐答案

方程SYTEM:

同方向(A,B,c)和1点X(X1,X2,X3)的线的parametrice方程是:

The parametrice equation of a line with direction (a,b,c) and one point X(x1,x2,x3) is :

D1:(x, y, z) = (x1, y1, z1) + t1(a, b, c)

使用2点A和B是一个行的parametrice方程:

The parametrice equation of a line with 2 points A and B is :

 D2:(x, y, z) = (xa, ya, za) + t2(xb-xa, yb-ya, zb-za)

您只需要平衡D1和D​​2得到结果发现参数t1和t2,将工作。 (3方程2未知数)

you just need to equalize D1 and D2 to get the result finding the parameter t1 and t2 that will work. (3 equations with 2 unknown)

如果没有办法解决没有交集。

If there is no solution there is no intersection.

路口与段唯一的:

现在令M是你导致你只需要验证:

Now let M be you result you just need to verify :

t2 in [0,1] 

 or  0<AM.AB<||AB||^2 (M is in the segment AB)

注:

如果您的线路的再presentation是从笛卡尔方程(计划交集)比问题是相同的,但有4个方程的3未知

If the representation of your line are from cartesian equations (intersection of plans) than the problem is the same but with 4 equations an 3 unknown

示例:

A (1,1,1)
B (0,0,0)
D2:(x,y,z)=(1-t2,1-t2,1-t2)

(a,b,c)=(1.-1.1)
(x1,y1,z1)=(1,0,1)
D1:(x,y,z)=(t1+1,-t1,1+t1)

(D1和D2是2对角线侧的立方体= 1放置在0,0,0的)

(D1 and D2 are 2 diagonals of the cube of side =1 placed on 0,0,0)

令M(X,Y,Z)是交叉点D1,D2

let M(x,y,z) be the intersection D1, D2

我们发现t1和t2是均衡上述等式:D1和D2

we find t1 and t2 that equalize the above equation: D1 and D2

我们得到轻松的 T1 = -1 / 2和t2 = 1/2

此外T2为[0,1],这样产生的交集是在[A,B]

moreover t2 is in [0,1] so the resulting intersection is in [A,B]

M(1 / 2,1 / 2,1 / 2)= D1(T1)= D2(T2)是解

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

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