Skip to content

Commit

Permalink
fixed the bug with the tester. Its weird that the broken tester worke…
Browse files Browse the repository at this point in the history
…d on my computer
  • Loading branch information
telephone001 committed Dec 9, 2023
1 parent ec37969 commit 666d692
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 37 deletions.
2 changes: 2 additions & 0 deletions include/cglm/euler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
125 changes: 88 additions & 37 deletions test/src/test_quat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 666d692

Please sign in to comment.