- Код: Выделить всё
Public Function GetAngleBetween(X1 As Single, Y1 As Single, X2 As Single, Y2 As Single) As Single
Dim alp As Single, DispX As Long, DispY As Long
DispX = X2 - X1
DispY = Y2 - Y1
If DispX = 0 Then
If DispY >= 0 Then alp = 0 Else alp = 180
GoTo 1
Else
If DispY = 0 Then
If DispX >= 0 Then alp = 90 Else alp = 270
GoTo 1
Else
alp = Atn(DispY / DispX) * 180 / PI
End If
End If
If DispX > 0 Then alp = 90 - alp Else alp = 270 - alp
1:
GetAngleBetween = alp
End Function
Не самый лучший метод, как видите
PS: Исправил, теперь намного лучше