pub fn decompose(a: f32, b: f32, c: f32, d: f32) -> (f32, f32, f32, f32)Expand description
The singular value decomposition of a 2x2, as (θ, φ, sx, sy) with
M = R(θ)·diag(sx, sy)·R(φ) and sy signed.
Closed form, not an iteration. Writing out R(θ)·diag·R(φ) and collecting
terms gives four combinations that separate cleanly:
(a+d)/2 = (sx+sy)/2 · cos(θ+φ) (c-b)/2 = (sx+sy)/2 · sin(θ+φ)
(a-d)/2 = (sx-sy)/2 · cos(θ-φ) (c+b)/2 = (sx-sy)/2 · sin(θ-φ)so the two magnitudes come from two hypotenuses and the two angle sums from
two atan2s. sx = Q + R and sy = Q - R — and because Q and R are
both non-negative, sy carries the sign of the determinant for free,
which is the reflection the fern’s f₄ needs. sx ≥ |sy| falls out the same
way, so sx is always the larger singular value.
σ₁σ₂ = det M checks every row; the round-trip test asserts it.