| Option Explicit
Public Const PI = 3.14159265358979
Public Function PointsToAngle(ByVal xOne As Double, ByVal yOne As _
Double, ByVal X As Double, ByVal Y As Double) As Double
If xOne = X And Y = yOne Then
Exit Function
End If
X = X - xOne
Y = Y - yOne
Dim nRatio As Double
Dim nASin As Double
nRatio = X / Sqr(Y ^ 2 + X ^ 2)
If Abs(nRatio) = 1 Then
nASin = 90 * nRatio
Else
nASin = Atn(nRatio / Sqr(-nRatio * nRatio + 1)) * (180 / PI)
End If
If Y < 0 Then
nASin = 90 - nASin + 90
ElseIf X < 0 Then
nASin = nASin + 360
End If
PointsToAngle = nASin
End Function
|