The Haversine Formula for AURORA #11
Madacool01
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This feed explains the logic behind the Haversine formula and how I am going to implement it in Python to calculate the distance between 2 GPS coordinates, taking into account latitude, longitude, and the Earth's curvature (this Pythagorean Theorem$a^2 + b^2 = c^2$ does not take this into account!). Heres how it goes:
$a=sin^2(\frac{\Delta \phi }{2})+cos(\phi _{1})\cdot cos(\phi _{2})\cdot sin^2(\frac{\Delta \lambda }{2})$
$c = 2\cdot atan2(\sqrt{a}, \sqrt{1-a})$
$d = R\cdot c$
$\phi{1}, \phi{2}$ are the latitudes of point 1 & point 2 in radians.
$\lambda_1, \lambda_2$ are the longitudes of point 1 and point 2 in radians.
$\Delta \phi = \phi_2 - \phi_1$ (the difference between the latitudes).
$\Delta \lambda = \lambda_2 - \lambda_1$ (the difference between the longitudes)
$a$ is the square of half the chord length between the two points.
$c$ is the angular distance in radians.
$R$ is the mean radius of the Earth ($\approx 6,371,000\text{ meters}$ or $6,371\text{ km}$ ).
$d$ is the final computed shortest distance between the two points along the surface of the sphere.
Where:
All reactions