diff --git a/agb-fixnum/src/lib.rs b/agb-fixnum/src/lib.rs index d61852ae..499c0d21 100644 --- a/agb-fixnum/src/lib.rs +++ b/agb-fixnum/src/lib.rs @@ -744,6 +744,17 @@ impl Vector2D { y: self.y.abs(), } } + + #[must_use] + /// Calculates the manhattan distance, x.abs() + y.abs(). + /// ``` + /// # use agb_fixnum::*; + /// let v1: Vector2D> = (num!(3.), num!(4.)).into(); + /// assert_eq!(v1.manhattan_distance(), 7.into()); + /// ``` + pub fn manhattan_distance(self) -> T { + self.x.abs() + self.y.abs() + } } impl Vector2D> { @@ -790,28 +801,6 @@ impl Vector2D> { } impl Vector2D> { - #[must_use] - /// Calculates the magnitude squared, ie (x*x + y*y) - /// ``` - /// # use agb_fixnum::*; - /// let v1: Vector2D> = (num!(3.), num!(4.)).into(); - /// assert_eq!(v1.magnitude_squared(), 25.into()); - /// ``` - pub fn magnitude_squared(self) -> Num { - self.x * self.x + self.y * self.y - } - - #[must_use] - /// Calculates the manhattan distance, x.abs() + y.abs(). - /// ``` - /// # use agb_fixnum::*; - /// let v1: Vector2D> = (num!(3.), num!(4.)).into(); - /// assert_eq!(v1.manhattan_distance(), 7.into()); - /// ``` - pub fn manhattan_distance(self) -> Num { - self.x.abs() + self.y.abs() - } - #[must_use] /// Calculates the magnitude by square root /// ``` @@ -1168,6 +1157,17 @@ impl Vector2D { y: self.x, } } + + #[must_use] + /// Calculates the magnitude squared, ie (x*x + y*y) + /// ``` + /// # use agb_fixnum::*; + /// let v1: Vector2D> = (num!(3.), num!(4.)).into(); + /// assert_eq!(v1.magnitude_squared(), 25.into()); + /// ``` + pub fn magnitude_squared(self) -> T { + self.x * self.x + self.y * self.y + } } impl> Neg for Vector2D {