summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Ellur <vivek.ellur@samsung.com>2015-10-30 03:59:21 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-10-31 02:12:06 +0100
commit6090073dee6b8a283a2d404efde8ec9205e485d9 (patch)
tree1727ccc45a328e9e66c82f13615fefc0520dacf3
parent0080ee0d607faa82a4376f9366ffb9e638a32f25 (diff)
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>
-rw-r--r--src/tests/eina/eina_test_quaternion.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tests/eina/eina_test_quaternion.c b/src/tests/eina/eina_test_quaternion.c
index 058ca3cfbb..e1b876b595 100644
--- a/src/tests/eina/eina_test_quaternion.c
+++ b/src/tests/eina/eina_test_quaternion.c
@@ -57,6 +57,22 @@ eina_matrix3_cmp(const Eina_Matrix3 *a, const Eina_Matrix3 *b)
57} 57}
58 58
59static inline Eina_Bool 59static inline Eina_Bool
60eina_matrix3_f16p16_cmp(const Eina_Matrix3_F16p16 *a, const Eina_Matrix3_F16p16 *b)
61{
62 if ((a->xx == b->xx) &&
63 (a->xy == b->xy) &&
64 (a->xz == b->xz) &&
65 (a->yx == b->yx) &&
66 (a->yy == b->yy) &&
67 (a->yz == b->yz) &&
68 (a->zx == b->zx) &&
69 (a->zy == b->zy) &&
70 (a->zz == b->zz))
71 return EINA_TRUE;
72 return EINA_FALSE;
73}
74
75static inline Eina_Bool
60eina_point_3d_cmp(const Eina_Point_3D *a, const Eina_Point_3D *b) 76eina_point_3d_cmp(const Eina_Point_3D *a, const Eina_Point_3D *b)
61{ 77{
62 if (FLOAT_CMP(a->x, b->x) && 78 if (FLOAT_CMP(a->x, b->x) &&
@@ -414,6 +430,29 @@ START_TEST(eina_test_quaternion_lerp)
414} 430}
415END_TEST 431END_TEST
416 432
433START_TEST(eina_test_quaternion_f16p16_rotate_matrix)
434{
435 Eina_Quaternion_F16p16 q = {65536, 65536, 65536, 0};
436 Eina_Point_3D_F16p16 r = { 65536, 65536, 65536 };
437 Eina_Point_3D_F16p16 c = { 0, 0, 0 }, res = {65536, 65536, 65536};
438 Eina_Matrix3_F16p16 m, mres = {-262144, 131072, 131072,
439 131072, -262144, 131072,
440 131072, 131072, -262144 };
441
442 eina_init();
443
444 eina_quaternion_f16p16_rotate(&r, &c, &q);
445 fail_if(r.x != res.x ||
446 r.y != res.y ||
447 r.z != res.z);
448
449 eina_quaternion_f16p16_rotation_matrix3_get(&m, &q);
450 fail_if(!eina_matrix3_f16p16_cmp(&m, &mres));
451
452 eina_shutdown();
453}
454END_TEST
455
417void 456void
418eina_test_quaternion(TCase *tc) 457eina_test_quaternion(TCase *tc)
419{ 458{
@@ -431,4 +470,5 @@ eina_test_quaternion(TCase *tc)
431 tcase_add_test(tc, eina_test_matrix_recompose); 470 tcase_add_test(tc, eina_test_matrix_recompose);
432 tcase_add_test(tc, eina_test_quaternion_f16p16_lerp); 471 tcase_add_test(tc, eina_test_quaternion_f16p16_lerp);
433 tcase_add_test(tc, eina_test_quaternion_lerp); 472 tcase_add_test(tc, eina_test_quaternion_lerp);
473 tcase_add_test(tc, eina_test_quaternion_f16p16_rotate_matrix);
434} 474}