UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

19 lines 1.58 kB
/** * Performs Singular Value Decomposition (SVD) on a 2x2 matrix, optimized for MLS-MPM. * * This function computes the SVD of a 2x2 matrix `m` such that m = U * Σ * V^T, where: * * - U is a 2x2 orthogonal matrix (rotation). * - Σ (sig) is a 2x2 diagonal matrix containing the singular values. * - V is a 2x2 orthogonal matrix (rotation). * * The function modifies U, sig, and V in-place. The input matrix `m` and the intermediate matrix `S` are overwritten during the computation. * The algorithm uses a closed-form solution and optimizations specific to 2x2 matrices, making it very fast. It also handles the case where the off-diagonal elements of the intermediate matrix S are close to zero, simplifying calculations. The results are transposed, consistent with the Taichi programming language. * @param {number[]} U Output: 2x2 orthogonal matrix (rotation), stored as a flattened array [c, s, -s, c]. Modified in-place. * @param {number[]} S Output: Intermediate 2x2 matrix, overwritten during calculation. Modified in-place. * @param {number[]} V Output: 2x2 orthogonal matrix (rotation), stored as a flattened array. Modified in-place. * @param {number[]} sig Output: 2x2 diagonal matrix containing singular values, stored as a flattened array [σ1, 0, 0, σ2]. Modified in-place. * @param {number[]} m Input: 2x2 matrix, stored as a flattened array [a, b, c, d], representing [[a, c], [b, d]]. Will be overwritten. */ export function m2_svd(U: number[], S: number[], V: number[], sig: number[], m: number[]): void; //# sourceMappingURL=m2_svd.d.ts.map