diff --git a/src/mathx.rs b/src/mathx.rs index fdf9165..b21a624 100644 --- a/src/mathx.rs +++ b/src/mathx.rs @@ -44,13 +44,22 @@ impl MatExt for Mat3 { } } +/// Represents a 2×2 matrix decomposed as O^T D O, where O is orthogonal and D is diagonal. +/// +/// Not every matrix can be decomposed like this, only that of a symmetric bilinear function. #[derive(Copy, Clone, Debug, PartialEq)] pub struct Decomp2 { + /// The orthogonal part. + /// + /// Using a non-orthogonal matrix will yield to incorrect results (but no UB). pub ortho: Mat2, + + /// The diagonal part. pub diag: Vec2, } impl Decomp2 { + /// Computes the square of this, more efficiently than doing that with a matrix. pub fn square(&self) -> Self { Self { ortho: self.ortho, @@ -58,6 +67,7 @@ impl Decomp2 { } } + /// Computes the inverse of this, more efficiently than doing that with a matrix. pub fn inverse(&self) -> Self { Self { ortho: self.ortho,