summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-05-07 01:49:41 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-05-07 01:49:41 +0000
commit48d9f440a9050c5c2b36ad9a14d6f39aba5640fa (patch)
tree0488a69c8a91e86bc720091dc7a612e30fe36ac2
parent271899d2c3ef0d4c781a70d74bbb36dfc51bdfe0 (diff)
eina: backport r70831.
SVN revision: 70832
-rw-r--r--ChangeLog4
-rw-r--r--src/lib/eina_fp.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e7dd7dd..2018cdf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,3 +47,7 @@
472012-03-16 Raphael Kubo da Costa 472012-03-16 Raphael Kubo da Costa
48 48
49 * Adjust Valgrind's CFLAGS to fix the build when it is in a non-default location. 49 * Adjust Valgrind's CFLAGS to fix the build when it is in a non-default location.
50
512012-05-06 Cedric Bail
52
53 * Fix a rounding issue near 1.0 for eina_f32p32_cos and eina_f32p32_sin.
diff --git a/src/lib/eina_fp.c b/src/lib/eina_fp.c
index 8984b49..d06bb08 100644
--- a/src/lib/eina_fp.c
+++ b/src/lib/eina_fp.c
@@ -449,7 +449,7 @@ eina_f32p32_cos(Eina_F32p32 a)
449 /* Find which case from 0 to 2 * PI */ 449 /* Find which case from 0 to 2 * PI */
450 remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI; 450 remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
451 451
452 interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2), 452 interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, (MAX_PREC - 1) * 2),
453 EINA_F32P32_PI); 453 EINA_F32P32_PI);
454 idx = eina_f32p32_int_to(interpol); 454 idx = eina_f32p32_int_to(interpol);
455 if (idx >= MAX_PREC) 455 if (idx >= MAX_PREC)
@@ -504,15 +504,15 @@ eina_f32p32_sin(Eina_F32p32 a)
504 /* Find which case from 0 to 2 * PI */ 504 /* Find which case from 0 to 2 * PI */
505 remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI; 505 remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
506 506
507 interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2), 507 interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, (MAX_PREC - 1) * 2),
508 EINA_F32P32_PI); 508 EINA_F32P32_PI);
509 idx = eina_f32p32_int_to(interpol); 509 idx = eina_f32p32_int_to(interpol);
510 if (idx >= MAX_PREC) 510 if (idx >= MAX_PREC)
511 idx = 2 * MAX_PREC - (idx + 1); 511 idx = 2 * MAX_PREC - (idx + 1);
512 512
513 index2 = idx + 1; 513 index2 = idx + 1;
514 if (index2 == MAX_PREC) 514 if (index2 == MAX_PREC)
515 index2 = idx - 1; 515 index2 = idx - 1;
516 516
517 result = eina_f32p32_add(eina_trigo[idx], 517 result = eina_f32p32_add(eina_trigo[idx],
518 eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx], 518 eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],