Public Shared Function GetFootOfPerpendicular(pt As XYZ, begin As XYZ, [end] As XYZ) As XYZ
Dim dx As Double = begin.X - [end].X
Dim dy As Double = begin.Y - [end].Y
If Math.Abs(dx) < 1E-08 AndAlso Math.Abs(dy) < 1E-08 Then
Return begin
End If
Dim u As Double = (pt.X - begin.X) * (begin.X - [end].X) + (pt.Y - begin.Y) * (begin.Y - [end].Y)
u = u / ((dx * dx) + (dy * dy))
'retVal.X = begin.X + u* dx;
' retVal.Y = begin.Y + u* dy;
Dim retVal As New XYZ(begin.X + u * dx, begin.Y + u * dy, XYZ.BasisZ.Z)
Return retVal
End Function
求点到一条直线的垂足点
猜你喜欢
转载自blog.csdn.net/laocooon/article/details/120132452
今日推荐
周排行