73. Mars Base Locations#

from math import radians, cos, sin, asin, sqrt
center_e = [102.1904, 38.39031]
drop_1_e = [102.196396,38.380364]
def rad_to_degree(rad):
    return rad*180/3.14
def haversine(lon1, lat1, lon2, lat2):
    """
    Calculate the great circle distance between two points 
    on the earth (specified in decimal degrees)
    """
    # convert decimal degrees to radians 
    lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
    # haversine formula 
    dlon = lon2 - lon1 
    dlat = lat2 - lat1 
    a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
    c = 2 * asin(sqrt(a)) 
    # Radius of earth in kilometers is 6371
    km = 6371* c
    return km
haversine( center_e[0], center_e[1], drop_1_e[0], drop_1_e[1] )
1.2232084722925936
radius_mars = 3390
rad_to_degree(1.2/radius_mars)
0.020291979031621665