Skip to content

shz_mat4x4_inverse_block_triangular

Markdown
void shz_mat4x4_inverse_block_triangular(const shz_mat4x4_t* mtx, shz_mat4x4_t* out) SHZ_NOEXCEPT;

Computes the inverse of a 4x4 matrix in block-triangular form.

NameTypeDescription
mtxconst shz_mat4x4_t *
outshz_mat4x4_t *

Nothing (void).

This is a special-case faster optimization for 4x4 matrices which take the form:

A = [ M b ]
[ 0 w ]

Where A is 4x4, M is 3x3, b is 3x1, and the bottom row is (0, 0, 0, w) with w != 0. For this block-triangular form, det(A) = det(M) * w. Then

inv(A) = [ inv(M) -inv(M) * b / w ]
[ 0 1/w ]
  • A regular 3D transform matrix is already in this form.
  • shz_mat4x4_inverse() will dynamically check whether to use this optimization.
  • shz_mat4x4_t and shz_mat2x2_t arguments must be 8-byte aligned. Unaligned data goes through the float[16] parameters of the _unaligned routines.