Document Decomp2

This commit is contained in:
numzero 2024-09-15 10:27:01 +03:00
parent f57ef1c141
commit e5221fbcf8

View File

@ -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)] #[derive(Copy, Clone, Debug, PartialEq)]
pub struct Decomp2 { pub struct Decomp2 {
/// The orthogonal part.
///
/// Using a non-orthogonal matrix will yield to incorrect results (but no UB).
pub ortho: Mat2, pub ortho: Mat2,
/// The diagonal part.
pub diag: Vec2, pub diag: Vec2,
} }
impl Decomp2 { impl Decomp2 {
/// Computes the square of this, more efficiently than doing that with a matrix.
pub fn square(&self) -> Self { pub fn square(&self) -> Self {
Self { Self {
ortho: self.ortho, 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 { pub fn inverse(&self) -> Self {
Self { Self {
ortho: self.ortho, ortho: self.ortho,