From 666d692dfb2a3f1b937d82976f87b5dff6961f91 Mon Sep 17 00:00:00 2001 From: John Choi Date: Fri, 8 Dec 2023 23:06:36 -0600 Subject: [PATCH] fixed the bug with the tester. Its weird that the broken tester worked on my computer --- include/cglm/euler.h | 2 + test/src/test_quat.h | 125 ++++++++++++++++++++++++++++++------------- 2 files changed, 90 insertions(+), 37 deletions(-) diff --git a/include/cglm/euler.h b/include/cglm/euler.h index 725a205..9f921f2 100644 --- a/include/cglm/euler.h +++ b/include/cglm/euler.h @@ -448,4 +448,6 @@ glm_euler_by_order(vec3 angles, glm_euler_seq ord, mat4 dest) { dest[3][3] = 1.0f; } + + #endif /* cglm_euler_h */ diff --git a/test/src/test_quat.h b/test/src/test_quat.h index 8a9f6cb..c167ca1 100644 --- a/test/src/test_quat.h +++ b/test/src/test_quat.h @@ -127,9 +127,13 @@ TEST_IMPL(GLM_PREFIX, euler_xyz_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in xyz order*/ - glm_quat_mul(rot_x, expected, expected); - glm_quat_mul(rot_y, expected, expected); - glm_quat_mul(rot_z, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); /*use my function to get the quaternion*/ glm_euler_xyz_quat(result, angles); @@ -166,9 +170,13 @@ TEST_IMPL(GLM_PREFIX, euler_xyz_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in xyz order*/ - glm_quat_mul(rot_x, expected, expected); - glm_quat_mul(rot_y, expected, expected); - glm_quat_mul(rot_z, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); /*use my function to get the quaternion*/ glm_euler_xyz_quat(result, angles); @@ -208,9 +216,13 @@ TEST_IMPL(GLM_PREFIX, euler_xzy_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in xzy order*/ - glm_quat_mul(rot_x, expected, expected); - glm_quat_mul(rot_z, expected, expected); - glm_quat_mul(rot_y, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); /*use my function to get the quaternion*/ glm_euler_xzy_quat(result, angles); @@ -246,9 +258,13 @@ TEST_IMPL(GLM_PREFIX, euler_xzy_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in xyz order*/ - glm_quat_mul(rot_x, expected, expected); - glm_quat_mul(rot_z, expected, expected); - glm_quat_mul(rot_y, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); /*use my function to get the quaternion*/ glm_euler_xzy_quat(result, angles); @@ -289,9 +305,13 @@ TEST_IMPL(GLM_PREFIX, euler_yxz_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in yxz order*/ - glm_quat_mul(rot_y, expected, expected); - glm_quat_mul(rot_x, expected, expected); - glm_quat_mul(rot_z, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); /*use my function to get the quaternion*/ glm_euler_yxz_quat(result, angles); @@ -326,10 +346,14 @@ TEST_IMPL(GLM_PREFIX, euler_yxz_quat) { glm_quatv(rot_y, angles[1], axis_y); glm_quatv(rot_z, angles[2], axis_z); - /*apply the rotations to a unit quaternion in xyz order*/ - glm_quat_mul(rot_y, expected, expected); - glm_quat_mul(rot_x, expected, expected); - glm_quat_mul(rot_z, expected, expected); + /*apply the rotations to a unit quaternion in yxz order*/ + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); /*use my function to get the quaternion*/ glm_euler_yxz_quat(result, angles); @@ -370,9 +394,13 @@ TEST_IMPL(GLM_PREFIX, euler_yzx_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in yzx order*/ - glm_quat_mul(rot_y, expected, expected); - glm_quat_mul(rot_z, expected, expected); - glm_quat_mul(rot_x, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); /*use my function to get the quaternion*/ glm_euler_yzx_quat(result, angles); @@ -408,9 +436,13 @@ TEST_IMPL(GLM_PREFIX, euler_yzx_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in yzx order*/ - glm_quat_mul(rot_y, expected, expected); - glm_quat_mul(rot_z, expected, expected); - glm_quat_mul(rot_x, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); /*use my function to get the quaternion*/ glm_euler_yzx_quat(result, angles); @@ -451,9 +483,13 @@ TEST_IMPL(GLM_PREFIX, euler_zxy_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in zxy order*/ - glm_quat_mul(rot_z, expected, expected); - glm_quat_mul(rot_x, expected, expected); - glm_quat_mul(rot_y, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); /*use my function to get the quaternion*/ glm_euler_zxy_quat(result, angles); @@ -489,9 +525,14 @@ TEST_IMPL(GLM_PREFIX, euler_zxy_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in zxy order*/ - glm_quat_mul(rot_z, expected, expected); - glm_quat_mul(rot_x, expected, expected); - glm_quat_mul(rot_y, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + /*use my function to get the quaternion*/ glm_euler_zxy_quat(result, angles); @@ -532,9 +573,14 @@ TEST_IMPL(GLM_PREFIX, euler_zyx_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in zyx order*/ - glm_quat_mul(rot_z, expected, expected); - glm_quat_mul(rot_y, expected, expected); - glm_quat_mul(rot_x, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + /*use my function to get the quaternion*/ glm_euler_zyx_quat(result, angles); @@ -571,9 +617,14 @@ TEST_IMPL(GLM_PREFIX, euler_zyx_quat) { glm_quatv(rot_z, angles[2], axis_z); /*apply the rotations to a unit quaternion in zyx order*/ - glm_quat_mul(rot_z, expected, expected); - glm_quat_mul(rot_y, expected, expected); - glm_quat_mul(rot_x, expected, expected); + versor tmp; + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_z, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_y, tmp, expected); + glm_quat_copy(expected, tmp); + glm_quat_mul(rot_x, tmp, expected); + /*use my function to get the quaternion*/ glm_euler_zyx_quat(result, angles);