Trait Bearing

Source
pub trait Bearing<F: CoordFloat> {
    // Required method
    fn bearing(&self, origin: Point<F>, destination: Point<F>) -> F;
}
Expand description

Calculate the bearing between two points.

Required Methods§

Source

fn bearing(&self, origin: Point<F>, destination: Point<F>) -> F

Calculate the bearing from origin to destination in degrees.

See specific implementations for details.

§Units
  • origin, destination: Point where the units of x/y depend on the trait implementation.
  • returns: degrees, where: North: 0°, East: 90°, South: 180°, West: 270°
§Examples
use geo::{Point, Haversine, Bearing, Geodesic};

let point_1 = Point::new(0.0, 0.0);
let point_2 = Point::new(0.0, 2.0);

// Due north
assert_eq!(Haversine.bearing(point_1, point_2), 0.0);
assert_eq!(Geodesic.bearing(point_1, point_2), 0.0);

Implementors§