From e5221fbcf8233c44b035e4e56e36646eec2ad7a4 Mon Sep 17 00:00:00 2001 From: numzero Date: Sun, 15 Sep 2024 10:27:01 +0300 Subject: [PATCH] Document Decomp2 --- src/mathx.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) 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,