| 2402 | // comment. :) |
| 2403 | COVERAGE(HMM_M4ToQ_RH, 4) |
| 2404 | static inline HMM_Quat HMM_M4ToQ_RH(HMM_Mat4 M) |
| 2405 | { |
| 2406 | float T; |
| 2407 | HMM_Quat Q; |
| 2408 | |
| 2409 | if (M.Elements[2][2] < 0.0f) { |
| 2410 | if (M.Elements[0][0] > M.Elements[1][1]) { |
| 2411 | ASSERT_COVERED(HMM_M4ToQ_RH); |
| 2412 | |
| 2413 | T = 1 + M.Elements[0][0] - M.Elements[1][1] - M.Elements[2][2]; |
| 2414 | Q = HMM_Q( |
| 2415 | T, |
| 2416 | M.Elements[0][1] + M.Elements[1][0], |
| 2417 | M.Elements[2][0] + M.Elements[0][2], |
| 2418 | M.Elements[1][2] - M.Elements[2][1] |
| 2419 | ); |
| 2420 | } else { |
| 2421 | ASSERT_COVERED(HMM_M4ToQ_RH); |
| 2422 | |
| 2423 | T = 1 - M.Elements[0][0] + M.Elements[1][1] - M.Elements[2][2]; |
| 2424 | Q = HMM_Q( |
| 2425 | M.Elements[0][1] + M.Elements[1][0], |
| 2426 | T, |
| 2427 | M.Elements[1][2] + M.Elements[2][1], |
| 2428 | M.Elements[2][0] - M.Elements[0][2] |
| 2429 | ); |
| 2430 | } |
| 2431 | } else { |
| 2432 | if (M.Elements[0][0] < -M.Elements[1][1]) { |
| 2433 | ASSERT_COVERED(HMM_M4ToQ_RH); |
| 2434 | |
| 2435 | T = 1 - M.Elements[0][0] - M.Elements[1][1] + M.Elements[2][2]; |
| 2436 | Q = HMM_Q( |
| 2437 | M.Elements[2][0] + M.Elements[0][2], |
| 2438 | M.Elements[1][2] + M.Elements[2][1], |
| 2439 | T, |
| 2440 | M.Elements[0][1] - M.Elements[1][0] |
| 2441 | ); |
| 2442 | } else { |
| 2443 | ASSERT_COVERED(HMM_M4ToQ_RH); |
| 2444 | |
| 2445 | T = 1 + M.Elements[0][0] + M.Elements[1][1] + M.Elements[2][2]; |
| 2446 | Q = HMM_Q( |
| 2447 | M.Elements[1][2] - M.Elements[2][1], |
| 2448 | M.Elements[2][0] - M.Elements[0][2], |
| 2449 | M.Elements[0][1] - M.Elements[1][0], |
| 2450 | T |
| 2451 | ); |
| 2452 | } |
| 2453 | } |
| 2454 | |
| 2455 | Q = HMM_MulQF(Q, 0.5f / HMM_SqrtF(T)); |
| 2456 | |
| 2457 | return Q; |
| 2458 | } |
| 2459 | |
| 2460 | COVERAGE(HMM_M4ToQ_LH, 4) |
| 2461 | static inline HMM_Quat HMM_M4ToQ_LH(HMM_Mat4 M) |