Thanks !
You show me the right solution :)
I finally use this 2D Math function from Jasu find inside the Code Archive :
Work perfectly !
You show me the right solution :)
I finally use this 2D Math function from Jasu find inside the Code Archive :
rem bbdoc:This function calculates the distance between a line segment and a point. endrem Function DistanceToLineSegment:Float (x1:Float, y1:Float, x2:Float, y2:Float, Px:Float, Py:Float) Local Dx:Float, Dy:Float, Ratio:Float If (x1 = x2) And (y1 = y2) Then Return Sqr( (Px-x1)*(Px-x1)+(Py-y1)*(Py-y1) ) Else Dx = x2 - x1 Dy = y2 - y1 Ratio = ((Px - x1) * Dx + (Py - y1) * Dy) / (Dx * Dx + Dy * Dy) If Ratio < 0 Then Return Sqr( (Px-x1)*(Px-x1)+(Py-y1)*(Py-y1) ) ElseIf Ratio > 1 Then Return Sqr( (Px-x2)*(Px-x2)+(Py-y2)*(Py-y2) ) Else Return Sqr ((Px - ((1 - Ratio) * x1 + Ratio * x2))*(Px - ((1 - Ratio) * x1 + Ratio * x2))+(Py - ((1 - Ratio) * y1 + Ratio * y2))*(Py - ((1 - Ratio) * y1 + Ratio * y2))) EndIf EndIf End Function
Work perfectly !