Kata > GreatCircle

A point on the Earth is defined by latitude and longitude.

Latitude and longitude are defined by degrees, minutes, and seconds.

There are 60 minutes in a degree and 60 seconds in a minute.

Latitudes North of the Equator are positive, those South, negative.

Longitudes East of the Greenwich Meridian are positive, those West, negative.

The radius of the Earth is approximately 6,371 km.

There are 0.017453 radians in a degree.

There are 1.852 kilometres in a nautical mile.

The Haversine Formula gives the great circle distance (d) between two points in terms of latitude in radians (λ) and longitude in radians (φ) where r is the radius of the Earth:

\[ d = 2 \: r \: arcsin \sqrt{sin ^2 \left( \frac{\phi_2 - \phi_1}{2} \right) + cos (\phi_1) \: cos(\phi_2) \: sin^2 \left( \frac{\lambda_2 - \lambda_1}{2} \right) } \]

Calculate the great circle distance between two given points in both nautical miles and kilometres.