eina_quaternion: add test cases for quaternion rotation functions

Summary:
Added test cases for eina_quaternion_f16p16_rotate and
eina_quaternion_f16p16_rotation_matrix3_get functions

Signed-off-by: Vivek Ellur <vivek.ellur@samsung.com>

Reviewers: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D3247

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Vivek Ellur 2015-10-30 03:59:21 +01:00 committed by Cedric BAIL
parent 0080ee0d60
commit 6090073dee
1 changed files with 40 additions and 0 deletions

View File

@ -56,6 +56,22 @@ eina_matrix3_cmp(const Eina_Matrix3 *a, const Eina_Matrix3 *b)
return EINA_FALSE;
}
static inline Eina_Bool
eina_matrix3_f16p16_cmp(const Eina_Matrix3_F16p16 *a, const Eina_Matrix3_F16p16 *b)
{
if ((a->xx == b->xx) &&
(a->xy == b->xy) &&
(a->xz == b->xz) &&
(a->yx == b->yx) &&
(a->yy == b->yy) &&
(a->yz == b->yz) &&
(a->zx == b->zx) &&
(a->zy == b->zy) &&
(a->zz == b->zz))
return EINA_TRUE;
return EINA_FALSE;
}
static inline Eina_Bool
eina_point_3d_cmp(const Eina_Point_3D *a, const Eina_Point_3D *b)
{
@ -414,6 +430,29 @@ START_TEST(eina_test_quaternion_lerp)
}
END_TEST
START_TEST(eina_test_quaternion_f16p16_rotate_matrix)
{
Eina_Quaternion_F16p16 q = {65536, 65536, 65536, 0};
Eina_Point_3D_F16p16 r = { 65536, 65536, 65536 };
Eina_Point_3D_F16p16 c = { 0, 0, 0 }, res = {65536, 65536, 65536};
Eina_Matrix3_F16p16 m, mres = {-262144, 131072, 131072,
131072, -262144, 131072,
131072, 131072, -262144 };
eina_init();
eina_quaternion_f16p16_rotate(&r, &c, &q);
fail_if(r.x != res.x ||
r.y != res.y ||
r.z != res.z);
eina_quaternion_f16p16_rotation_matrix3_get(&m, &q);
fail_if(!eina_matrix3_f16p16_cmp(&m, &mres));
eina_shutdown();
}
END_TEST
void
eina_test_quaternion(TCase *tc)
{
@ -431,4 +470,5 @@ eina_test_quaternion(TCase *tc)
tcase_add_test(tc, eina_test_matrix_recompose);
tcase_add_test(tc, eina_test_quaternion_f16p16_lerp);
tcase_add_test(tc, eina_test_quaternion_lerp);
tcase_add_test(tc, eina_test_quaternion_f16p16_rotate_matrix);
}