import math

lonCurrent = 87.19325
latCurrent = 30.50188

lonWant = 87.19112
latWant = 30.50214 


def calculate_initial_compass_bearing(lon1, lat1, lon2, lat2):

    lat1 = math.radians(lat1)
    lon1 = math.radians(lon1)
    lat2 = math.radians(lat2)
    lon2 = math.radians(lon2)

    diffLong = lon2-lon1

    x = math.sin(diffLong) * math.cos(lat2)
    y = math.cos(lat1) * math.sin(lat2) - (math.sin(lat1) * math.cos(lat2) * math.cos(diffLong))

    initial_bearing = math.atan2(x, y)

    # Now we have the initial bearing but math.atan2 return values
    # from -180 to + 180 which is not what we want for a compass bearing
    # The solution is to normalize the initial bearing as shown below
    initial_bearing = math.degrees(initial_bearing)
    compass_bearing = (initial_bearing + 360) % 360
    compass_bearing = abs(compass_bearing-360)
    return compass_bearing


print(calculate_initial_compass_bearing(lonCurrent, latCurrent, lonWant, latWant))
