The Haversine formula is used to calculate the distance between two points on the surface of a sphere, such as the Earth. It takes into account the latitude and longitude of both points and calculates the shortest distance between them, often referred to as the "as-the-crow-flies" distance.
The formula is given by:
a = sin²(Δlat/2) + cos(lat1) * cos(lat2) * sin²(Δlon/2) c = 2 * atan2(√a, √(1-a)) distance = R * c
Where: