mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +11:00
Add manhattan distance method
This commit is contained in:
parent
52a97594fd
commit
100764b38c
|
@ -550,6 +550,10 @@ impl<const N: usize> Vector2D<Num<i32, N>> {
|
||||||
self.x * self.x + self.y * self.y
|
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> {
|
pub fn magnitude(self) -> Num<i32, N> {
|
||||||
self.magnitude_squared().sqrt()
|
self.magnitude_squared().sqrt()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue