Matrix3ToQuaternion
function · cmath · primitive
- Address
0x7c0120· 77 bytes, up to0x7c016c- Signature
NTempest::C4Quaternion * __thiscall (NTempest::C4Quaternion *this, const NTempest::C33Matrix *m)- Meaning
- Copies a 3x3 matrix transposed into a local and converts it to a quaternion through 0x7c0190
- 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.
Callers 2
- SyncLightNode terrain
- CParticleEmitter2::InitModelParticle models
Callees 1
- MatrixToQuaternion cmath
Calls and jumps by a bare address, from tables/calls.tsv.