Add magnitude synonym functions for ease of use
This commit is contained in:
parent
4b6a69bb99
commit
787d20cff4
|
@ -1166,6 +1166,26 @@ impl<N: Real, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
|
|||
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<N, R, C>
|
||||
|
|
|
@ -176,6 +176,26 @@ impl<N: Real> Quaternion<N> {
|
|||
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 {
|
||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -418,6 +418,18 @@ pub fn norm_squared<V: NormedSpace>(v: &V) -> V::Field {
|
|||
v.norm_squared()
|
||||
}
|
||||
|
||||
/// A synonym function for `norm()` aka length.
|
||||
#[inline]
|
||||
pub fn magnitude<V: NormedSpace>(v: &V) -> V::Field {
|
||||
v.norm()
|
||||
}
|
||||
|
||||
/// A synonym function for `norm_squared()` aka length squared.
|
||||
#[inline]
|
||||
pub fn magnitude_squared<V: NormedSpace>(v: &V) -> V::Field {
|
||||
v.norm_squared()
|
||||
}
|
||||
|
||||
/// Computes the normalized version of the vector `v`.
|
||||
#[inline]
|
||||
pub fn normalize<V: NormedSpace>(v: &V) -> V {
|
||||
|
|
Loading…
Reference in New Issue