Merge pull request #69 from gwilymk/manhattan_distance

Add manhattan distance method
This commit is contained in:
Corwin 2021-06-12 21:16:59 +01:00 committed by GitHub
commit bfb0c10b53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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()
}