geokit/bearing
Initial and final compass bearing between two LatLng points.
Bearings are reported in degrees clockwise from true north, in
[0, 360). The initial bearing is the direction of travel when
departing a along the great-circle route to b; the final
bearing is the direction of arrival at b. The two differ along
any route except along a meridian or the equator (where they are
equal).
Formula: https://www.movable-type.co.uk/scripts/latlong.html.
Values
pub fn final(
from from: latlng.LatLng,
to to: latlng.LatLng,
) -> Float
Final bearing when arriving at to along the great-circle route
from from, in degrees in [0, 360). Computed as the reverse of
initial(from: to, to: from) plus 180°.
pub fn initial(
from from: latlng.LatLng,
to to: latlng.LatLng,
) -> Float
Initial bearing (forward azimuth) from a to b, in degrees in
[0, 360).
import geokit/bearing
import geokit/latlng
let assert Ok(tokyo) = latlng.new(lat: 35.6812, lng: 139.7671)
let assert Ok(osaka) = latlng.new(lat: 34.6937, lng: 135.5023)
bearing.initial(from: tokyo, to: osaka)
// ~= 254.0