怎样计算平面内两条线段的最短距离
怎样计算平面内两条线段的最短距离
平面内线段的位置是任意的,已知两条线段四个端点的坐标.最好不要角方程,通过程序可计算的
自己也找到了算法逻辑,贴出来服务大家吧,
AB and CD are line segments
Solving the above for r and s yields
r = ((Ay-Cy)(Dx-Cx)-(Ax-Cx)(Dy-Cy))/((Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)) ------ (eqn 1)
s = ((Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay))/((Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)) ------ (eqn 2)
Let Point be the position vector of the intersection point,then
Point=A+r(B-A) or
Px=Ax+r(Bx-Ax)
Py=Ay+r(By-Ay)
By examining the values of r & s,you can also determine some other
limiting conditions:
If 0
平面内线段的位置是任意的,已知两条线段四个端点的坐标.最好不要角方程,通过程序可计算的
自己也找到了算法逻辑,贴出来服务大家吧,
AB and CD are line segments
Solving the above for r and s yields
r = ((Ay-Cy)(Dx-Cx)-(Ax-Cx)(Dy-Cy))/((Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)) ------ (eqn 1)
s = ((Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay))/((Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)) ------ (eqn 2)
Let Point be the position vector of the intersection point,then
Point=A+r(B-A) or
Px=Ax+r(Bx-Ax)
Py=Ay+r(By-Ay)
By examining the values of r & s,you can also determine some other
limiting conditions:
If 0
数学人气:744 ℃时间:2020-05-25 02:00:26
优质解答
Mathematica 版本的.
我来回答
类似推荐
猜你喜欢
- 1我这次初一期末考语文试卷有几道题没写好,作文也没写好,怎么办
- 2如果a是有理数,n是正整数.分别指出在满足什么条件时,下列等式能成立:(1)-an=an;(2)(-a)n=an
- 3The capital of mexico is the City of Mexico.(yes or no)
- 4已知正方形面积为10平方厘米,那么正方形的内接圆的面积是多少平方厘米?
- 5关于对手的作文600字
- 6用一批纸装订练习本,每本40页,可以装订180本,如果每本45页,可以装订多少本?
- 7谁能帮我想一个英文单词、表达爱意、但打头字母是sc
- 8由苯合成2-苯基-2-丙醇
- 9甲、乙两地相距216KM,客车、货车同时从甲、乙两地相向而行.已知客车每小时行58KM,货车每小时行50KM,到
- 10以“月”为主题的情景交融借景抒情的片段