Public Const pi As Double = 3.14159265358979
Public Function Azimuth(x1 As Double, y1 As Double, x2 As Double, y2 As Double) As Double
Dim dx As Double, dy As Double, temp As Double
dx = x2 - x1: dy = y2 - y1
If dy <> 0 Then
temp = pi * (1 - Sgn(dy) / 2) - Atn(dx / dy)
Azimuth = temp * 180 / pi
Else
Azimuth = IIf(dx > 0, 0, 180)
End If
End Function
全部评论