我想计算两个点之间的航向,方向是P1(lat1,long2)和P2(lat2 long2),在excel中。
答案 0 :(得分:0)
我有一个用于火腿无线电计算的功能。一个“纯粹”的公式对我来说太笨重了。
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
答案 1 :(得分:0)
这取决于您要寻找的精度水平。 Haversine公式(请参阅Wikipedia)很简单,但可能会不足,因为它假定地球表面是一个完美的球体-并非如此。
Vincenty的公式提供了更好的精度(〜1000x和1/2 mm)。我汇总的Excel实现可在GitHub上找到:https://github.com/tdjastrzebski/Vincenty-Excel
VincentyInvFwdAzimuth()
功能可以满足您的需求。