Add degrees getter for cardinal directions.
This commit is contained in:
parent
42513e7912
commit
5dbc6510bc
10
src/core.rs
10
src/core.rs
|
@ -1,5 +1,6 @@
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{max, min},
|
cmp::{max, min},
|
||||||
|
f32::consts::PI,
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
ops::{Add, AddAssign, Sub, SubAssign},
|
ops::{Add, AddAssign, Sub, SubAssign},
|
||||||
|
@ -282,6 +283,15 @@ impl CardinalDirection {
|
||||||
_ => East,
|
_ => 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<Angle> for CardinalDirection {
|
impl From<Angle> for CardinalDirection {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user