'Calculates the angle between 2 lines defined by 2 points each
'cordinates line 1 point1 : x11, y11
'cordinates line 1 point2 : x12, y12
'cordinates line 2 point1 : x21, y21
'cordinates line 2 point1 : x22, y22
'Degrees = True result in degrees, Degrees = False result in radians
'Mode360 = True 0 - 360 Mode360 = False 0 -180 - 0
Public Sub CalcAngleBetween2Lines(xx11 As Double, yy11 As Double, xx12 As Double, yy12 As Double, xx21 As Double, yy21 As Double, xx22 As Double, yy22 As Double, Degree As Boolean, Mode360 As Boolean) As Double
Private Angle As Double
If Mode360 = True Then
Angle = ATan2D(y12 - y11, x12 - x11) - ATan2D(y22 - y21, x22 - x21)
If Angle < 0 Then
Angle = 360 + Angle
End If
Else
Angle = Abs((ATan2D(y12 - y11, x12 - x11) - ATan2D(y22 - y21, x22 - x21)))
If Angle > 180 Then
Angle = 360 - Angle
End If
End If
If Degree = True Then
Return Angle
Else
Return Angle *cPI / 180
End If
End Sub