Python code for Great circle navigation
import math
def great_circle_navigation(lat1, lon1, lat2, lon2):
R = 6371 # Earth's radius in km
# Convert degrees to radians
lat1, lon1, lat2, lon2 = map(math.radians, [lat1, lon1, lat2, lon2])
# Calculate the difference between the longitudes
delta_lon = lon2 - lon1
# Calculate the great circle distance
d = math.acos(math.sin(lat1) * math.sin(lat2) + math.cos(lat1) * math.cos(lat2) * math.cos(delta_lon)) * R
# Calculate the initial bearing
y = math.sin(delta_lon) * math.cos(lat2)
x = math.cos(lat1) * math.sin(lat2) - math.sin(lat1) * math.cos(lat2) * math.cos(delta_lon)
bearing = math.atan2(y, x)
# Convert bearing from radians to degrees
bearing = math.degrees(bearing)
return d, bearing
Here, lat1, lon1 are the latitude and longitude of the starting point, and lat2, lon2 are the latitude and longitude of the destination point. The function returns the great circle distance in kilometers (d) and the initial bearing from the starting point to the destination point in degrees (bearing).