Module frame

Module frame 

Source
Expand description

The IFC Z-up to WebGL Y-up frame, defined once.

S maps (x, y, z) to (x, z, -y); a proper rotation (det +1), so S⁻¹ = Sᵀ maps (x, y, z) to (x, -z, y).

  • Points and vectors swap components. The swap never folds the sign of zero: -y of +0.0 is -0.0, in every copy on main.
  • Boxes reverse min/max on the negated axis (aabb_zup_to_yup).
  • Matrices are conjugated, M' = S·M·Sᵀ. Conjugating by a signed permutation moves each entry to M'[r][c] = s(r)·s(c)·M[p(r)][p(c)], so it is done as exactly that, with + 0.0 folding the sign of zero. For every finite input this is bit-equal to the S·M·Sᵀ matmul (each matmul output is 0.0 + .. + (±m), which is ±m with every zero positive). It is storage-agnostic: conjugation commutes with transposition, so it applies to row- and column-major arrays alike. A non-finite entry stays in its own slot instead of spreading NaN across a row.

Constants§

YUP_TO_ZUP
Sᵀ.
ZUP_TO_YUP
S as a row-major 4x4 (linear part only).

Functions§

aabb_zup_to_yup
Swap an AABB [minx, miny, minz, maxx, maxy, maxz] from Z-up to Y-up. Swapping min/max per component is WRONG: negating Y flips which corner is the min along the new Z, so the new Z range is [-maxY, -minY].
conjugate3_zup_to_yup
conjugate_zup_to_yup for a 3x3 rotation.
conjugate_yup_to_zup
Sᵀ·M·S, the inverse of conjugate_zup_to_yup.
conjugate_zup_to_yup
S·M·Sᵀ for a Z-up matrix, as a signed permutation (see the module docs).
yup_to_zup
(x, y, z) to (x, -z, y), the inverse of zup_to_yup.
zup_to_yup
(x, y, z) to (x, z, -y). Generic so f32 vertex buffers and f64 origins share it; it monomorphises in the caller and always inlines.
zup_to_yup_in_place
zup_to_yup over a flat x, y, z, ... buffer. Only complete triplets are rewritten; a 1-2 float tail is left alone.