From 01ca857de7b61b491f54b462d3ddfe6f18868289 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 9 Jul 2024 03:14:53 -0400 Subject: Rotation of directions --- src/utils.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index 9f2e0d2..af0d77d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -60,6 +60,15 @@ impl Cardinal { Self::East => 3.0 * std::f32::consts::PI / 2.0, } } + + pub fn turn_by(&self, o: &Self) -> Self { + match o { + Self::North => self.clone(), + Self::South => self.turn_cw().turn_cw(), + Self::West => self.turn_cw(), + Self::East => self.turn_ccw(), + } + } } pub fn lerp(a: f32, b: f32, t: f32) -> f32 { -- cgit v1.2.3