0
我想在Excel中用P1(lat1,long2)和P2(lat2 long2)從北向兩點計算航向。從excel中計算經度和緯度的航向
我想在Excel中用P1(lat1,long2)和P2(lat2 long2)從北向兩點計算航向。從excel中計算經度和緯度的航向
我有一個功能用於火腿無線電計算。一個「純粹」的公式對我來說太笨重了。
Function BearingFromCoord(lat_base_deg, long_base_deg, lat_dest_deg, long_dest_deg As Single) As Long
Dim rad_deg_factor As Single
Dim long_diff As Single
Dim frac0 As Single
Dim frac1 As Single
Dim frac2 As Single
Dim lat_base As Single
Dim long_base As Single
Dim lat_dest As Single
Dim long_dest As Single
Dim bearing As Single
rad_deg_factor = 360/(2 * pi())
long_diff = (long_base_deg - long_dest_deg)/rad_deg_factor
lat_base = lat_base_deg/rad_deg_factor
lat_dest = lat_dest_deg/rad_deg_factor
frac0 = Sin(lat_base) * Sin(lat_dest) _
+ Cos(lat_base) * Cos(lat_dest) _
* Cos(long_diff)
bearing = rad_deg_factor * Application.WorksheetFunction.Acos((Sin(lat_dest) _
- Sin(lat_base) * frac0) _
/(Cos(lat_base) * Sin(WorksheetFunction.Acos(frac0))))
If Sin(long_diff) < 0 Then
BearingFromCoord = bearing
Else
BearingFromCoord = 360 - bearing
End If
End Function
Private Function pi() As Single
pi = 3.1415926535
End Function
你這樣做的問題到底是什麼?幾秒鐘,谷歌給了我這個:http://www.movable-type.co.uk/scripts/latlong.html –