mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 08:41:34 +11:00
Merge pull request #69 from gwilymk/manhattan_distance
Add manhattan distance method
This commit is contained in:
commit
bfb0c10b53
|
@ -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