From 0a38e65d267bfc8e86dc6e48f04cb45a514c8f99 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 21 Sep 2022 13:56:00 -0500 Subject: [PATCH] Add `yaw()` to `Transform`. --- src/core.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core.rs b/src/core.rs index 68c5504..aebc240 100644 --- a/src/core.rs +++ b/src/core.rs @@ -479,6 +479,17 @@ impl From<&dyn PointLike> for (i32, i32) { } } +pub trait TransformExt { + fn yaw(&self) -> Angle; +} + +impl TransformExt for Transform { + fn yaw(&self) -> Angle { + let forward = self.right(); + Angle::Radians(forward.y.atan2(forward.x)) + } +} + pub trait GlobalTransformExt { fn yaw(&self) -> Angle;