Calculate Latitutde-Longitude Difference
Convert all latitude and longitude values to radians. Calculate the difference in latitude (DLAT) and longitude (DLONG) between the two points:
DLAT = latitude1 - latitude2
DLONG = longitude1 - longitude 2
Interim Calculation Step 1
Calculate the value of an intermediate value A with the following formula:
A = sin(DLAT / 2)^2 + cos(latitude1) * cos(latitude2) * sin(DLONG / 2)^2
"Sin" and "cos" are the trigonometric functions sine and cosine and the caret (^) indicates raising to a power.
Interim Calculation Step 2
Calculate the value of an intermediate variable C by the following formula:
C = 2 * (atan2(A^0.5, (1-A)^0.5))
Atan2 is the trigonometric function arctangent.
Calculate Distance
Multiply the intermediate value C by the radius of the Earth (6,371 km or 3,959 miles) to obtain the shortest distance between the two points.