eina: fix a rounding issue in eina_f32p32_{cos,sin} when getting close to 1.0.
authorCedric BAIL <cedric.bail@free.fr>
Mon, 7 May 2012 01:46:37 +0000 (01:46 +0000)
committerCedric BAIL <cedric.bail@free.fr>
Mon, 7 May 2012 01:46:37 +0000 (01:46 +0000)
Bug only showed up if above 0.999 .

SVN revision: 70831

legacy/eina/ChangeLog
legacy/eina/NEWS
legacy/eina/src/lib/eina_fp.c

index 7e4cb51..6e284e3 100644 (file)
 2012-04-30  Jérôme Pinot
 
        * Add missing files in the tarballs.
+
+2012-05-06  Cedric Bail
+
+       * Fix a rounding issue near 1.0 for eina_f32p32_cos and eina_f32p32_sin.
index 37b3d31..b6f0c90 100644 (file)
@@ -8,6 +8,7 @@ Additions:
 
 Fixes:
     * Add missing files in the tarball.
+    * Rounding issue with eina_f32p32_cos and eina_f32p32_sin when getting close to 1.0.
 
 Eina 1.2.0
 
index 8984b49..d06bb08 100644 (file)
@@ -449,7 +449,7 @@ eina_f32p32_cos(Eina_F32p32 a)
    /* Find which case from 0 to 2 * PI */
    remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
 
-   interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
+   interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, (MAX_PREC - 1) * 2),
                               EINA_F32P32_PI);
    idx = eina_f32p32_int_to(interpol);
    if (idx >= MAX_PREC)
@@ -504,15 +504,15 @@ eina_f32p32_sin(Eina_F32p32 a)
    /* Find which case from 0 to 2 * PI */
    remainder_2PI = a - (a / F32P32_2PI) * F32P32_2PI;
 
-   interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, MAX_PREC * 2),
+   interpol = eina_f32p32_div(eina_f32p32_scale(remainder_PI, (MAX_PREC - 1) * 2),
                               EINA_F32P32_PI);
    idx = eina_f32p32_int_to(interpol);
    if (idx >= MAX_PREC)
-      idx = 2 * MAX_PREC - (idx + 1);
+     idx = 2 * MAX_PREC - (idx + 1);
 
    index2 = idx + 1;
    if (index2 == MAX_PREC)
-      index2 = idx - 1;
+     index2 = idx - 1;
 
    result = eina_f32p32_add(eina_trigo[idx],
                             eina_f32p32_mul(eina_f32p32_sub(eina_trigo[idx],