added flight mechanics
This commit is contained in:
17
simulator/utils.py
Normal file
17
simulator/utils.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import math
|
||||
|
||||
|
||||
def haversine_nm(lat1, lon1, lat2, lon2):
|
||||
# Earth radius in nautical miles
|
||||
R = 3440.065
|
||||
phi1, phi2 = math.radians(lat1), math.radians(lat2)
|
||||
dphi = math.radians(lat2 - lat1)
|
||||
dlambda = math.radians(lon2 - lon1)
|
||||
|
||||
a = (
|
||||
math.sin(dphi / 2) ** 2
|
||||
+ math.cos(phi1) * math.cos(phi2) * math.sin(dlambda / 2) ** 2
|
||||
)
|
||||
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
|
||||
|
||||
return R * c
|
Reference in New Issue
Block a user