mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
euler: fix thetaY in extracting angles
This commit is contained in:
@@ -76,7 +76,6 @@ glm_euler_angles(mat4 m, vec3 dest) {
|
|||||||
m01 = m[0][1]; m11 = m[1][1]; m21 = m[2][1];
|
m01 = m[0][1]; m11 = m[1][1]; m21 = m[2][1];
|
||||||
m22 = m[2][2];
|
m22 = m[2][2];
|
||||||
|
|
||||||
thetaY = 0.0f;
|
|
||||||
if (m20 < 1.0f) {
|
if (m20 < 1.0f) {
|
||||||
if (m20 > -1.0f) {
|
if (m20 > -1.0f) {
|
||||||
thetaY = asinf(m20);
|
thetaY = asinf(m20);
|
||||||
@@ -84,10 +83,11 @@ glm_euler_angles(mat4 m, vec3 dest) {
|
|||||||
thetaZ = atan2f(-m10, m00);
|
thetaZ = atan2f(-m10, m00);
|
||||||
} else { /* m20 == -1 */
|
} else { /* m20 == -1 */
|
||||||
/* Not a unique solution */
|
/* Not a unique solution */
|
||||||
|
thetaY = -CGLM_PI_2;
|
||||||
thetaX = -atan2f(m01, m11);
|
thetaX = -atan2f(m01, m11);
|
||||||
thetaZ = 0.0f;
|
thetaZ = 0.0f;
|
||||||
}
|
}
|
||||||
} else {/* m20 == +1 */
|
} else { /* m20 == +1 */
|
||||||
thetaY = CGLM_PI_2;
|
thetaY = CGLM_PI_2;
|
||||||
thetaX = atan2f(m01, m11);
|
thetaX = atan2f(m01, m11);
|
||||||
thetaZ = 0.0f;
|
thetaZ = 0.0f;
|
||||||
@@ -98,7 +98,6 @@ glm_euler_angles(mat4 m, vec3 dest) {
|
|||||||
dest[2] = thetaZ;
|
dest[2] = thetaZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief build rotation matrix from euler angles
|
* @brief build rotation matrix from euler angles
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ main(int argc, const char * argv[]) {
|
|||||||
cmocka_unit_test(test_clamp),
|
cmocka_unit_test(test_clamp),
|
||||||
|
|
||||||
/* euler */
|
/* euler */
|
||||||
cmocka_unit_test(test_euler)
|
cmocka_unit_test(test_euler)
|
||||||
};
|
};
|
||||||
|
|
||||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user