uwacan.positional.bearing_to#
- bearing_to(lat_1, lon_1, lat_2, lon_2)[source]#
Calculate the heading from one coordinate to another.
Conventions here are λ as the longitude and φ as the latitude. The implementation is based on spherical trigonometry, with conversions to geocentric coordinates. This can be written as
\[\begin{split}Δx &= \cos(φ_1) \sin(φ_2) - \sin(φ_1)\cos(φ_2)\cos(φ_2 - φ_1) \\ Δy &= \sin(λ_2 - λ_1)\cos(φ_2) \\ θ &= \arctan(Δy/Δx)\end{split}\]- Parameters:
- lat_1float
Latitude of the first point in degrees.
- lon_1float
Longitude of the first point in degrees.
- lat_2float
Latitude of the second point in degrees.
- lon_2float
Longitude of the second point in degrees.
- Returns:
- float
Bearing from the first point to the second point in degrees, wrapped to (-180, 180].