Add manhattan distance method

This commit is contained in:
Gwilym Kuiper 2021-06-12 21:02:31 +01:00
parent 52a97594fd
commit 100764b38c

View file

@ -550,6 +550,10 @@ impl<const N: usize> Vector2D<Num<i32, N>> {
self.x * self.x + self.y * self.y
}
pub fn manhattan_distance(self) -> Num<i32, N> {
self.x.abs() + self.y.abs()
}
pub fn magnitude(self) -> Num<i32, N> {
self.magnitude_squared().sqrt()
}