怎样计算平面内两条线段的最短距离
来源:学生作业帮 编辑:搜狗做题网作业帮 分类:数学作业 时间:2024/08/19 01:07:12
怎样计算平面内两条线段的最短距离
平面内线段的位置是任意的,已知两条线段四个端点的坐标.最好不要角方程,通过程序可计算的
自己也找到了算法逻辑,贴出来服务大家吧,
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
![怎样计算平面内两条线段的最短距离](/uploads/image/z/6411553-25-3.jpg?t=%E6%80%8E%E6%A0%B7%E8%AE%A1%E7%AE%97%E5%B9%B3%E9%9D%A2%E5%86%85%E4%B8%A4%E6%9D%A1%E7%BA%BF%E6%AE%B5%E7%9A%84%E6%9C%80%E7%9F%AD%E8%B7%9D%E7%A6%BB)
Mathematica 版本的.