loxodrome_direct
function loxodrome_inverse(lon1, lat1, lon2, lat2, a=6378137.0, f=0.0033528106647474805)
Compute the inverse problem of a loxodrome on the ellipsoid.
Given latitudes and longitudes of P1 and P2 on the ellipsoid, compute the azimuth a12 of the loxodrome P1P2, the arc length s along the loxodrome curve.
Args:
lon1, lat1, lon2, lat2: - longitude and latitude of starting and end points (degrees).a- major axis of the ellipsoid (meters). Default values for WGS84f- flattening od the ellipsoid (default = 1 / 298.257223563)
References:
Returns
- Distance (meters) and azimuth from P1 to P2
Example: Compute the distance and azimuth beyween points (0,0) and (5,5)
dist, azim = loxodrome_inverse(0,0,5,5)
““” function loxodrome_inverse(lon1, lat1, lon2, lat2, a=6378137.0, f=0.0033528106647474805) D2R = pi / 180 lon1 = D2R; lat1 = D2R lon2 = D2R; lat2 = D2R e2 = f * (2 - f)
isolat1 = isometric_lat(lat1, e2)
isolat2 = isometric_lat(lat2, e2)
# Compute changes in isometric latitude and longitude between P1 and P2
Az12 = atan((lon2 - lon1), (isolat2 - isolat1)) # The azimuth
# Compute distance along loxodromic curve
m1 = meridian_dist(lat1, a, e2)
m2 = meridian_dist(lat2, a, e2)
lox_s = (m2 - m1) / cos(Az12);
return lox_s, Az12 / D2R
end