'角度化弧度
Public Function Radian(a As Double) As Double
Dim Ra As Double
Dim c As Double
Dim FS As Double
Dim Ib As Integer
Dim Ic As Integer
Ra = pi / 180#
Ib = Int(a)
c = (a - Ib) * 100#
Ic = Int(c)
FS = (c - Ic) * 100#
Radian = (Ib + Ic / 60# + FS / 3600#) * Ra
End Function
'弧度化角度
Public Function Degree(a As Double) As Double
Dim B As Double
Dim Fs1 As Double
Dim Im1 As Integer
Dim Id1 As Integer
B = a
Call DMS(B, Id1, Im1, Fs1)
Degree = Id1 + Im1 / 100# + Fs1 / 10000#
End Function
Public Sub DMS(a As Double, ID As Integer, IM As Integer, FS As Double)
Dim B As Double
Dim c As Double
c = a
c = 180# / pi * c
ID = Int(c + 0.0000005)
B = (c - ID) * 60 + 0.0005
IM = Int(B)
FS = (B - IM) * 60
End Sub
'计算两点间的方位角
Public Function azimuth(x1 As Double, y1 As Double, x2 As Double, y2 As Double) As Single
Dim dx As Double
Dim dy As Double
Dim fwj As Double
dx = x2 - x1
dy = y2 - y1
If dy <> 0 Then
fwj = pi * (1 - Sgn(dy) / 2) - Atn(dx / dy)
azimuth = Degree(fwj)
Else
If dx > 0 Then
azimuth = 0
Else
azimuth = 180
End If
End If
End Function