solution_069.py

#!/usr/bin/python3
# ===================================================================
# solution to round earth problem
# ===================================================================

import numpy as np

# ---- earth radius and circumference (2*Pi*r)
radius_ml        = 3959
radius_km        = 6371
circumference_ml = 24875.11
circumference_km = 40030.14

# ---- sailboat mast height (feet)
mast_height = [ 50, 100, 150, 200, 250, 300, 350, 400, 450, 500 ]

# ---- generate data (degrees, miles)

for mst_ft in mast_height:

    mst_ml = mst_ft / 5280.0             # mast height (miles)

    hyp = radius_ml + mst_ml             # hypotenuse (miles)

    rad = np.arccos(radius_ml / hyp)     # radians

    deg = np.degrees(rad)                # degrees

    dst = circumference_ml * (deg/360.0) # distance (miles)

    print(f'mast_height = {mst_ft:3} (feet) ' + \
          f'degrees = {deg:.3}  '    + \
          f'distance = {dst:.6} miles')