benilla-re systems structs docs

s_nextAxis

global · cmath

Address
0x81d994 · 12 bytes, up to 0x81d99f
Type
const uint32_t[3]
Meaning
Holds 1, 2, 0, the next axis of each axis for the matrix to quaternion conversion
Confidence
verified, proof two
Finding
cmath/quaternions#matrix-to-quaternion

Finding: Matrix to quaternion in cmath: quaternions

0x7c0190(m) converts a 3×3 row-major rotation matrix (nine packed floats, m[r*3+c]) to a quaternion in ecx. With the trace t = (m11 + m00) + m22 above 0: s = √(t + 1), w = 0.5·s, k = 0.5/s and x = (m21 − m12)·k, y = (m02 − m20)·k, z = (m10 − m01)·k. Otherwise i is the index of the largest diagonal entry, the later index winning only when strictly greater, j = next[i], k = next[j] with next = {1, 2, 0}; s = √(1 + m_ii − m_jj − m_kk), q[i] = 0.5·s, w = (m_kj − m_jk)·(0.5/s), q[j] = (m_ij + m_ji)·(0.5/s), q[k] = (m_ik + m_ki)·(0.5/s).

The derivation is in the doc.