summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-01-06 09:57:46 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-01-06 15:58:46 -0800
commit8f1c071d6adbf6f8e2002eeeabdc7f3d7be9ef22 (patch)
tree17bddaa85bcdead8807053b009d1adf1c9eda71c /src/lib/eina
parentf9928b75c8c4a2e6c3f02aafb68c8a569a47ab04 (diff)
eina: rename EINA_{FLT,DBL}_CMP to EINA_{FLT,DBL}_EQ.
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_bezier.c8
-rw-r--r--src/lib/eina/eina_matrix.c90
-rw-r--r--src/lib/eina/eina_quaternion.c22
-rw-r--r--src/lib/eina/eina_util.h6
4 files changed, 64 insertions, 62 deletions
diff --git a/src/lib/eina/eina_bezier.c b/src/lib/eina/eina_bezier.c
index 391bf14359..b179ceb59e 100644
--- a/src/lib/eina/eina_bezier.c
+++ b/src/lib/eina/eina_bezier.c
@@ -226,7 +226,7 @@ eina_bezier_t_at(const Eina_Bezier *b, double l)
226 double biggest = 1.0; 226 double biggest = 1.0;
227 double t = 1.0; 227 double t = 1.0;
228 228
229 if (l >= len)// || (EINA_DBL_CMP(len, l))) 229 if (l >= len)// || (EINA_DBL_EQ(len, l)))
230 return t; 230 return t;
231 231
232 t *= 0.5; 232 t *= 0.5;
@@ -240,7 +240,7 @@ eina_bezier_t_at(const Eina_Bezier *b, double l)
240 _eina_bezier_split_left(&right, t, &left); 240 _eina_bezier_split_left(&right, t, &left);
241 ll = eina_bezier_length_get(&left); 241 ll = eina_bezier_length_get(&left);
242 242
243 if (EINA_DBL_CMP(ll, l)) 243 if (EINA_DBL_EQ(ll, l))
244 break; 244 break;
245 245
246 if (ll < l) 246 if (ll < l)
@@ -317,8 +317,8 @@ eina_bezier_on_interval(Eina_Bezier *b, double t0, double t1, Eina_Bezier *resul
317 Eina_Bezier bezier; 317 Eina_Bezier bezier;
318 double t; 318 double t;
319 319
320 if (EINA_DBL_CMP(t0, 0.0) && 320 if (EINA_DBL_EQ(t0, 0.0) &&
321 EINA_DBL_CMP(t1, 1.0)) 321 EINA_DBL_EQ(t1, 1.0))
322 { 322 {
323 *result = *b; 323 *result = *b;
324 return; 324 return;
diff --git a/src/lib/eina/eina_matrix.c b/src/lib/eina/eina_matrix.c
index 43da6c7021..50439dd755 100644
--- a/src/lib/eina/eina_matrix.c
+++ b/src/lib/eina/eina_matrix.c
@@ -106,18 +106,18 @@ _cos(double x)
106EAPI Eina_Matrix_Type 106EAPI Eina_Matrix_Type
107eina_matrix3_type_get(const Eina_Matrix3 *m) 107eina_matrix3_type_get(const Eina_Matrix3 *m)
108{ 108{
109 if (!EINA_DBL_CMP(MATRIX_ZX(m), 0.0) || 109 if (!EINA_DBL_EQ(MATRIX_ZX(m), 0.0) ||
110 !EINA_DBL_CMP(MATRIX_ZY(m), 0.0) || 110 !EINA_DBL_EQ(MATRIX_ZY(m), 0.0) ||
111 !EINA_DBL_CMP(MATRIX_ZZ(m), 1.0)) 111 !EINA_DBL_EQ(MATRIX_ZZ(m), 1.0))
112 return EINA_MATRIX_TYPE_PROJECTIVE; 112 return EINA_MATRIX_TYPE_PROJECTIVE;
113 else 113 else
114 { 114 {
115 if (EINA_DBL_CMP(MATRIX_XX(m), 1.0) && 115 if (EINA_DBL_EQ(MATRIX_XX(m), 1.0) &&
116 EINA_DBL_CMP(MATRIX_XY(m), 0.0) && 116 EINA_DBL_EQ(MATRIX_XY(m), 0.0) &&
117 EINA_DBL_CMP(MATRIX_XZ(m), 0.0) && 117 EINA_DBL_EQ(MATRIX_XZ(m), 0.0) &&
118 EINA_DBL_CMP(MATRIX_YX(m), 0.0) && 118 EINA_DBL_EQ(MATRIX_YX(m), 0.0) &&
119 EINA_DBL_CMP(MATRIX_YY(m), 1.0) && 119 EINA_DBL_EQ(MATRIX_YY(m), 1.0) &&
120 EINA_DBL_CMP(MATRIX_YZ(m), 0.0)) 120 EINA_DBL_EQ(MATRIX_YZ(m), 0.0))
121 return EINA_MATRIX_TYPE_IDENTITY; 121 return EINA_MATRIX_TYPE_IDENTITY;
122 else 122 else
123 return EINA_MATRIX_TYPE_AFFINE; 123 return EINA_MATRIX_TYPE_AFFINE;
@@ -127,22 +127,22 @@ eina_matrix3_type_get(const Eina_Matrix3 *m)
127EAPI Eina_Matrix_Type 127EAPI Eina_Matrix_Type
128eina_matrix4_type_get(const Eina_Matrix4 *m) 128eina_matrix4_type_get(const Eina_Matrix4 *m)
129{ 129{
130 if (EINA_DBL_CMP(MATRIX_XX(m), 1.0) && 130 if (EINA_DBL_EQ(MATRIX_XX(m), 1.0) &&
131 EINA_DBL_CMP(MATRIX_XY(m), 0.0) && 131 EINA_DBL_EQ(MATRIX_XY(m), 0.0) &&
132 EINA_DBL_CMP(MATRIX_XZ(m), 0.0) && 132 EINA_DBL_EQ(MATRIX_XZ(m), 0.0) &&
133 EINA_DBL_CMP(MATRIX_XW(m), 0.0) && 133 EINA_DBL_EQ(MATRIX_XW(m), 0.0) &&
134 EINA_DBL_CMP(MATRIX_YX(m), 0.0) && 134 EINA_DBL_EQ(MATRIX_YX(m), 0.0) &&
135 EINA_DBL_CMP(MATRIX_YY(m), 1.0) && 135 EINA_DBL_EQ(MATRIX_YY(m), 1.0) &&
136 EINA_DBL_CMP(MATRIX_YZ(m), 0.0) && 136 EINA_DBL_EQ(MATRIX_YZ(m), 0.0) &&
137 EINA_DBL_CMP(MATRIX_YW(m), 0.0) && 137 EINA_DBL_EQ(MATRIX_YW(m), 0.0) &&
138 EINA_DBL_CMP(MATRIX_ZX(m), 0.0) && 138 EINA_DBL_EQ(MATRIX_ZX(m), 0.0) &&
139 EINA_DBL_CMP(MATRIX_ZY(m), 0.0) && 139 EINA_DBL_EQ(MATRIX_ZY(m), 0.0) &&
140 EINA_DBL_CMP(MATRIX_ZZ(m), 1.0) && 140 EINA_DBL_EQ(MATRIX_ZZ(m), 1.0) &&
141 EINA_DBL_CMP(MATRIX_ZW(m), 0.0) && 141 EINA_DBL_EQ(MATRIX_ZW(m), 0.0) &&
142 EINA_DBL_CMP(MATRIX_WX(m), 0.0) && 142 EINA_DBL_EQ(MATRIX_WX(m), 0.0) &&
143 EINA_DBL_CMP(MATRIX_WY(m), 0.0) && 143 EINA_DBL_EQ(MATRIX_WY(m), 0.0) &&
144 EINA_DBL_CMP(MATRIX_WZ(m), 0.0) && 144 EINA_DBL_EQ(MATRIX_WZ(m), 0.0) &&
145 EINA_DBL_CMP(MATRIX_WW(m), 1.0)) 145 EINA_DBL_EQ(MATRIX_WW(m), 1.0))
146 return EINA_MATRIX_TYPE_IDENTITY; 146 return EINA_MATRIX_TYPE_IDENTITY;
147 return EINA_MATRIX_TYPE_AFFINE; 147 return EINA_MATRIX_TYPE_AFFINE;
148} 148}
@@ -280,8 +280,8 @@ eina_matrix3_point_transform(const Eina_Matrix3 *m,
280{ 280{
281 double xrr, yrr; 281 double xrr, yrr;
282 282
283 if (!EINA_DBL_CMP(MATRIX_ZX(m), 0.0) && 283 if (!EINA_DBL_EQ(MATRIX_ZX(m), 0.0) &&
284 !EINA_DBL_CMP(MATRIX_ZY(m), 0.0)) 284 !EINA_DBL_EQ(MATRIX_ZY(m), 0.0))
285 { 285 {
286 xrr = (x * MATRIX_XX(m) + y * MATRIX_XY(m) + MATRIX_XZ(m)); 286 xrr = (x * MATRIX_XX(m) + y * MATRIX_XY(m) + MATRIX_XZ(m));
287 yrr = (x * MATRIX_YX(m) + y * MATRIX_YY(m) + MATRIX_YZ(m)); 287 yrr = (x * MATRIX_YX(m) + y * MATRIX_YY(m) + MATRIX_YZ(m));
@@ -401,7 +401,7 @@ eina_matrix3_inverse(const Eina_Matrix3 *m, Eina_Matrix3 *m2)
401 401
402 /* determinant */ 402 /* determinant */
403 scalar = eina_matrix3_determinant(m); 403 scalar = eina_matrix3_determinant(m);
404 if (EINA_DBL_CMP(scalar, 0.0)) 404 if (EINA_DBL_EQ(scalar, 0.0))
405 { 405 {
406 eina_matrix3_identity(m2); 406 eina_matrix3_identity(m2);
407 return; 407 return;
@@ -445,15 +445,15 @@ eina_matrix3_compose(const Eina_Matrix3 *m1,
445EAPI Eina_Bool 445EAPI Eina_Bool
446eina_matrix3_equal(const Eina_Matrix3 *m1, const Eina_Matrix3 *m2) 446eina_matrix3_equal(const Eina_Matrix3 *m1, const Eina_Matrix3 *m2)
447{ 447{
448 if (!EINA_DBL_CMP(m1->xx, m2->xx) || 448 if (!EINA_DBL_EQ(m1->xx, m2->xx) ||
449 !EINA_DBL_CMP(m1->xy, m2->xy) || 449 !EINA_DBL_EQ(m1->xy, m2->xy) ||
450 !EINA_DBL_CMP(m1->xz, m2->xz) || 450 !EINA_DBL_EQ(m1->xz, m2->xz) ||
451 !EINA_DBL_CMP(m1->yx, m2->yx) || 451 !EINA_DBL_EQ(m1->yx, m2->yx) ||
452 !EINA_DBL_CMP(m1->yy, m2->yy) || 452 !EINA_DBL_EQ(m1->yy, m2->yy) ||
453 !EINA_DBL_CMP(m1->yz, m2->yz) || 453 !EINA_DBL_EQ(m1->yz, m2->yz) ||
454 !EINA_DBL_CMP(m1->zx, m2->zx) || 454 !EINA_DBL_EQ(m1->zx, m2->zx) ||
455 !EINA_DBL_CMP(m1->zy, m2->zy) || 455 !EINA_DBL_EQ(m1->zy, m2->zy) ||
456 !EINA_DBL_CMP(m1->zz, m2->zz)) 456 !EINA_DBL_EQ(m1->zz, m2->zz))
457 return EINA_FALSE; 457 return EINA_FALSE;
458 return EINA_TRUE; 458 return EINA_TRUE;
459} 459}
@@ -602,7 +602,7 @@ eina_matrix3_square_quad_map(Eina_Matrix3 *m, const Eina_Quad *q)
602 double ey = QUAD_Y0(q) - QUAD_Y1(q) + QUAD_Y2(q) - QUAD_Y3(q); 602 double ey = QUAD_Y0(q) - QUAD_Y1(q) + QUAD_Y2(q) - QUAD_Y3(q);
603 603
604 /* paralellogram */ 604 /* paralellogram */
605 if (EINA_DBL_CMP(ex, 0.0) && EINA_DBL_CMP(ey, 0.0)) 605 if (EINA_DBL_EQ(ex, 0.0) && EINA_DBL_EQ(ey, 0.0))
606 { 606 {
607 /* create the affine matrix */ 607 /* create the affine matrix */
608 MATRIX_XX(m) = QUAD_X1(q) - QUAD_X0(q); 608 MATRIX_XX(m) = QUAD_X1(q) - QUAD_X0(q);
@@ -627,7 +627,7 @@ eina_matrix3_square_quad_map(Eina_Matrix3 *m, const Eina_Quad *q)
627 double dy2 = QUAD_Y3(q) - QUAD_Y2(q); // y3 - y2 627 double dy2 = QUAD_Y3(q) - QUAD_Y2(q); // y3 - y2
628 double den = (dx1 * dy2) - (dx2 * dy1); 628 double den = (dx1 * dy2) - (dx2 * dy1);
629 629
630 if (EINA_DBL_CMP(den, 0.0)) 630 if (EINA_DBL_EQ(den, 0.0))
631 return EINA_FALSE; 631 return EINA_FALSE;
632 632
633 MATRIX_ZX(m) = ((ex * dy2) - (dx2 * ey)) / den; 633 MATRIX_ZX(m) = ((ex * dy2) - (dx2 * ey)) / den;
@@ -656,7 +656,7 @@ eina_matrix3_quad_square_map(Eina_Matrix3 *m,
656 656
657 eina_matrix3_inverse(&tmp, m); 657 eina_matrix3_inverse(&tmp, m);
658 /* make the projective matrix3 always have 1 on zz */ 658 /* make the projective matrix3 always have 1 on zz */
659 if (!EINA_DBL_CMP(MATRIX_ZZ(m), 1.0)) 659 if (!EINA_DBL_EQ(MATRIX_ZZ(m), 1.0))
660 { 660 {
661 eina_matrix3_divide(m, MATRIX_ZZ(m)); 661 eina_matrix3_divide(m, MATRIX_ZZ(m));
662 } 662 }
@@ -989,10 +989,10 @@ eina_matrix4_identity(Eina_Matrix4 *out)
989EAPI Eina_Matrix_Type 989EAPI Eina_Matrix_Type
990eina_matrix2_type_get(const Eina_Matrix2 *m) 990eina_matrix2_type_get(const Eina_Matrix2 *m)
991{ 991{
992 if (EINA_DBL_CMP(MATRIX_XX(m), 1.0) && 992 if (EINA_DBL_EQ(MATRIX_XX(m), 1.0) &&
993 EINA_DBL_CMP(MATRIX_XY(m), 0.0) && 993 EINA_DBL_EQ(MATRIX_XY(m), 0.0) &&
994 EINA_DBL_CMP(MATRIX_YX(m), 0.0) && 994 EINA_DBL_EQ(MATRIX_YX(m), 0.0) &&
995 EINA_DBL_CMP(MATRIX_YY(m), 1.0)) 995 EINA_DBL_EQ(MATRIX_YY(m), 1.0))
996 return EINA_MATRIX_TYPE_IDENTITY; 996 return EINA_MATRIX_TYPE_IDENTITY;
997 return EINA_MATRIX_TYPE_AFFINE; 997 return EINA_MATRIX_TYPE_AFFINE;
998} 998}
@@ -1238,7 +1238,7 @@ eina_matrix2_inverse(Eina_Matrix2 *out, const Eina_Matrix2 *mat)
1238 1238
1239 det = MATRIX_XX(mat) * MATRIX_YY(mat) - MATRIX_YX(mat) * MATRIX_XY(mat); 1239 det = MATRIX_XX(mat) * MATRIX_YY(mat) - MATRIX_YX(mat) * MATRIX_XY(mat);
1240 1240
1241 if (EINA_DBL_CMP(det, 0.0)) 1241 if (EINA_DBL_EQ(det, 0.0))
1242 return; 1242 return;
1243 1243
1244 det = 1.0 / det; 1244 det = 1.0 / det;
diff --git a/src/lib/eina/eina_quaternion.c b/src/lib/eina/eina_quaternion.c
index 93dbb31d7a..f3431e0326 100644
--- a/src/lib/eina/eina_quaternion.c
+++ b/src/lib/eina/eina_quaternion.c
@@ -447,12 +447,12 @@ eina_quaternion_lerp(Eina_Quaternion *out,
447 const Eina_Quaternion *b, 447 const Eina_Quaternion *b,
448 double pos) 448 double pos)
449{ 449{
450 if (EINA_DBL_CMP(pos, 0.0)) 450 if (EINA_DBL_EQ(pos, 0.0))
451 { 451 {
452 *out = *a; 452 *out = *a;
453 return ; 453 return ;
454 } 454 }
455 else if (EINA_DBL_CMP(pos, 1.0)) 455 else if (EINA_DBL_EQ(pos, 1.0))
456 { 456 {
457 *out = *b; 457 *out = *b;
458 return ; 458 return ;
@@ -475,12 +475,12 @@ eina_quaternion_slerp(Eina_Quaternion *out,
475 double dot; 475 double dot;
476 double pos1, pos2; 476 double pos1, pos2;
477 477
478 if (EINA_DBL_CMP(pos, 0.0)) 478 if (EINA_DBL_EQ(pos, 0.0))
479 { 479 {
480 *out = *a; 480 *out = *a;
481 return ; 481 return ;
482 } 482 }
483 else if (EINA_DBL_CMP(pos, 1.0)) 483 else if (EINA_DBL_EQ(pos, 1.0))
484 { 484 {
485 *out = *b; 485 *out = *b;
486 return ; 486 return ;
@@ -528,12 +528,12 @@ eina_quaternion_nlerp(Eina_Quaternion *out,
528 Eina_Quaternion not_normalize; 528 Eina_Quaternion not_normalize;
529 double dot; 529 double dot;
530 530
531 if (EINA_DBL_CMP(pos, 0.0)) 531 if (EINA_DBL_EQ(pos, 0.0))
532 { 532 {
533 *out = *a; 533 *out = *a;
534 return ; 534 return ;
535 } 535 }
536 else if (EINA_DBL_CMP(pos, 1.0)) 536 else if (EINA_DBL_EQ(pos, 1.0))
537 { 537 {
538 *out = *b; 538 *out = *b;
539 return ; 539 return ;
@@ -692,7 +692,7 @@ eina_matrix4_quaternion_to(Eina_Quaternion *rotation,
692 Eina_Matrix4 n, pm; 692 Eina_Matrix4 n, pm;
693 double det, factor; 693 double det, factor;
694 694
695 if (EINA_DBL_CMP(m->ww, 0.0)) return EINA_FALSE; 695 if (EINA_DBL_EQ(m->ww, 0.0)) return EINA_FALSE;
696 696
697 // Normalize the matrix. 697 // Normalize the matrix.
698 factor = 1 / m->ww; 698 factor = 1 / m->ww;
@@ -932,7 +932,7 @@ eina_quaternion_matrix4_to(Eina_Matrix4 *m,
932 932
933 // apply skew 933 // apply skew
934 // rm is a identity 4x4 matrix initially 934 // rm is a identity 4x4 matrix initially
935 if (!EINA_DBL_CMP(skew->z, 0.0)) 935 if (!EINA_DBL_EQ(skew->z, 0.0))
936 { 936 {
937 Eina_Matrix4 cp; 937 Eina_Matrix4 cp;
938 938
@@ -943,7 +943,7 @@ eina_quaternion_matrix4_to(Eina_Matrix4 *m,
943 tmp = cp; 943 tmp = cp;
944 } 944 }
945 945
946 if (!EINA_DBL_CMP(skew->y, 0.0)) 946 if (!EINA_DBL_EQ(skew->y, 0.0))
947 { 947 {
948 Eina_Matrix4 cp; 948 Eina_Matrix4 cp;
949 949
@@ -955,7 +955,7 @@ eina_quaternion_matrix4_to(Eina_Matrix4 *m,
955 tmp = cp; 955 tmp = cp;
956 } 956 }
957 957
958 if (!EINA_DBL_CMP(skew->x, 0.0)) 958 if (!EINA_DBL_EQ(skew->x, 0.0))
959 { 959 {
960 Eina_Matrix4 cp; 960 Eina_Matrix4 cp;
961 961
@@ -1029,7 +1029,7 @@ eina_quaternion_copy(Eina_Quaternion *dst, const Eina_Quaternion *src)
1029EAPI void 1029EAPI void
1030eina_quaternion_homogeneous_regulate(Eina_Quaternion *out, const Eina_Quaternion *v) 1030eina_quaternion_homogeneous_regulate(Eina_Quaternion *out, const Eina_Quaternion *v)
1031{ 1031{
1032 if (!EINA_DBL_CMP(v->w, 0.0)) 1032 if (!EINA_DBL_EQ(v->w, 0.0))
1033 { 1033 {
1034 double scale = 1.0 / v->w; 1034 double scale = 1.0 / v->w;
1035 1035
diff --git a/src/lib/eina/eina_util.h b/src/lib/eina/eina_util.h
index fab96177d7..ef3089ed4b 100644
--- a/src/lib/eina/eina_util.h
+++ b/src/lib/eina/eina_util.h
@@ -73,10 +73,11 @@ EAPI Eina_Bool eina_flteq(float a, float b);
73 * @brief Safe comparison of float 73 * @brief Safe comparison of float
74 * @param a First member to compar 74 * @param a First member to compar
75 * @param b Second member to compar 75 * @param b Second member to compar
76 * @since 1.19
76 * 77 *
77 * @return @c true if two floats match 78 * @return @c true if two floats match
78 */ 79 */
79#define EINA_FLT_CMP(a, b) (fabsf((float)a - (float)b) <= FLT_EPSILON) 80#define EINA_FLT_EQ(a, b) (!!(fabsf((float)a - (float)b) <= FLT_EPSILON))
80 81
81/** 82/**
82 * @brief Determine if a float is nonzero 83 * @brief Determine if a float is nonzero
@@ -91,10 +92,11 @@ EAPI Eina_Bool eina_flteq(float a, float b);
91 * @brief Safe comparison of double 92 * @brief Safe comparison of double
92 * @param a First member to compar 93 * @param a First member to compar
93 * @param b Second member to compar 94 * @param b Second member to compar
95 * @since 1.19
94 * 96 *
95 * @return @c true if two double match 97 * @return @c true if two double match
96 */ 98 */
97#define EINA_DBL_CMP(a, b) (fabs((double)a - (double)b) <= DBL_EPSILON) 99#define EINA_DBL_EQ(a, b) (!!(fabs((double)a - (double)b) <= DBL_EPSILON))
98 100
99/** 101/**
100 * @brief Determine if a double is nonzero 102 * @brief Determine if a double is nonzero