From 100764b38c73f104f100ccc59700d3963e640b78 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Sat, 12 Jun 2021 21:02:31 +0100 Subject: [PATCH] Add manhattan distance method --- agb/src/number.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/agb/src/number.rs b/agb/src/number.rs index 8f354b5e..a4f0238d 100644 --- a/agb/src/number.rs +++ b/agb/src/number.rs @@ -550,6 +550,10 @@ impl Vector2D> { self.x * self.x + self.y * self.y } + pub fn manhattan_distance(self) -> Num { + self.x.abs() + self.y.abs() + } + pub fn magnitude(self) -> Num { self.magnitude_squared().sqrt() }