Algorithm to Add new link to a Line

BlitzMax Forums/BlitzMax Programming/Algorithm to Add new link to a Line

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Thanks !
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 !