MCPcopy Create free account
hub / github.com/doldecomp/mkdd / stMtx2Qt

Function stMtx2Qt

src/Sato/stMath.cpp:271–326  ·  view source on GitHub ↗

TODO: match it in a way that makes sense https://decomp.me/scratch/2u8r1

Source from the content-addressed store, hash-verified

269// TODO: match it in a way that makes sense
270// https://decomp.me/scratch/2u8r1
271void stMtx2Qt(Quaternion *q, const Mtx m)
272{
273 f32 x = m[0][0];
274 f32 y = m[1][1];
275 f32 z = m[2][2];
276 f32 length = x + y + z;
277 if (length > 0.0f)
278 {
279 length = std::sqrtf(1.0f + length);
280 f32 t = 0.5f / length;
281 q->w = 0.5f * length;
282 q->x = t * (m[2][1] - m[1][2]);
283 q->y = t * (m[0][2] - m[2][0]);
284 q->z = t * (m[1][0] - m[0][1]);
285 }
286 else
287 {
288 f32 direction = x;
289 if (y > x)
290 {
291 direction = m[1][1];
292 }
293 else if (z > x)
294 {
295 direction = m[2][2];
296 }
297
298 if (direction == x)
299 {
300 x = stspeedy_sqrtf(1.0f + (x - (y + z)));
301 f32 t = 0.5f / x;
302 q->x = 0.5f * x;
303 q->y = t * (m[0][1] + m[1][0]);
304 q->z = t * (m[2][0] + m[0][2]);
305 q->w = t * (m[2][1] - m[1][2]);
306 }
307 else if (direction == y)
308 {
309 x = stspeedy_sqrtf(1.0f + (y - (z + x)));
310 f32 t = 0.5f / x;
311 q->y = 0.5f * x;
312 q->z = t * (m[1][2] + m[2][1]);
313 q->x = t * (m[0][1] + m[1][0]);
314 q->w = t * (m[0][2] - m[2][0]);
315 }
316 else
317 {
318 x = stspeedy_sqrtf(1.0f + (z - (x + y)));
319 f32 t = 0.5f / x;
320 q->z = 0.5f * x;
321 q->x = t * (m[2][0] + m[0][2]);
322 q->y = t * (m[1][2] + m[2][1]);
323 q->w = t * (m[1][0] - m[0][1]);
324 }
325 }
326}
327
328void stQtLerp(Quaternion *dst, const Quaternion *p, const Quaternion *q, float t)

Callers 7

doUnivInitReleaseMethod · 0.85
doFirstRotateMethod · 0.85
initReleaseMethod · 0.85
doUnivReleaseMethod · 0.85
calcRotQuatMethod · 0.85
initReleaseMethod · 0.85
moveCommonMethod · 0.85

Calls 2

sqrtfFunction · 0.85
stspeedy_sqrtfFunction · 0.85

Tested by

no test coverage detected