diff --git a/src/core.rs b/src/core.rs index ababec2..ed5bec8 100644 --- a/src/core.rs +++ b/src/core.rs @@ -1,5 +1,6 @@ use std::{ cmp::{max, min}, + f32::consts::PI, fmt::Display, marker::PhantomData, ops::{Add, AddAssign, Sub, SubAssign}, @@ -282,6 +283,15 @@ impl CardinalDirection { _ => East, } } + + pub fn angle(&self) -> Angle { + match self { + CardinalDirection::North => Angle::Radians(PI / 2.), + CardinalDirection::East => Angle::Radians(0.), + CardinalDirection::South => Angle::Radians(-PI / 2.), + CardinalDirection::West => Angle::Radians(PI), + } + } } impl From for CardinalDirection {