diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 2c7c673a..0fff3efc 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -1166,6 +1166,26 @@ impl> Matrix { self.norm_squared().sqrt() } + /// A synonym for the norm of this matrix. + /// + /// Aka the length. + /// + /// This function is simply implemented as a call to `norm()` + #[inline] + pub fn magnitude(&self) -> N { + self.norm() + } + + /// A synonym for the squared norm of this matrix. + /// + /// Aka the squared length. + /// + /// This function is simply implemented as a call to `norm_squared()` + #[inline] + pub fn magnitude_squared(&self) -> N { + self.norm_squared() + } + /// Returns a normalized version of this matrix. #[inline] pub fn normalize(&self) -> MatrixMN diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index 47b62d6c..3196b94c 100644 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -176,6 +176,26 @@ impl Quaternion { self.coords.norm() } + /// A synonym for the norm of this quaternion. + /// + /// Aka the length. + /// + /// This function is simply implemented as a call to `norm()` + #[inline] + pub fn magnitude(&self) -> N { + self.norm() + } + + /// A synonym for the squared norm of this quaternion. + /// + /// Aka the squared length. + /// + /// This function is simply implemented as a call to `norm_squared()` + #[inline] + pub fn magnitude_squared(&self) -> N { + self.norm_squared() + } + /// The squared norm of this quaternion. #[inline] pub fn norm_squared(&self) -> N { diff --git a/src/lib.rs b/src/lib.rs index 8268f682..a1a4a5b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -418,6 +418,18 @@ pub fn norm_squared(v: &V) -> V::Field { v.norm_squared() } +/// A synonym function for `norm()` aka length. +#[inline] +pub fn magnitude(v: &V) -> V::Field { + v.norm() +} + +/// A synonym function for `norm_squared()` aka length squared. +#[inline] +pub fn magnitude_squared(v: &V) -> V::Field { + v.norm_squared() +} + /// Computes the normalized version of the vector `v`. #[inline] pub fn normalize(v: &V) -> V {