[goffice] Complex: simplify using go_sinpi etc.



commit 8ebc5c94729358ed58c1830901ee6114ede7863c
Author: Morten Welinder <terra gnome org>
Date:   Wed Dec 18 13:34:38 2013 -0500

    Complex: simplify using go_sinpi etc.

 ChangeLog                 |    3 +++
 goffice/math/go-complex.c |   40 ++++++----------------------------------
 2 files changed, 9 insertions(+), 34 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bb0e01e..2ce95a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2013-12-18  Morten Welinder  <terra gnome org>
 
+       * goffice/math/go-complex.c (go_complex_from_polar_pi): Use
+       go_sinpi and go_cospi.
+
        * goffice/math/go-math.c (go_sinpi, go_cospi, go_tanpi): New
        functions.
 
diff --git a/goffice/math/go-complex.c b/goffice/math/go-complex.c
index 8db1ec0..99a2bf2 100644
--- a/goffice/math/go-complex.c
+++ b/goffice/math/go-complex.c
@@ -193,45 +193,17 @@ SUFFIX(go_complex_to_polar) (DOUBLE *mod, DOUBLE *angle, COMPLEX const *src)
 void
 SUFFIX(go_complex_from_polar) (COMPLEX *dst, DOUBLE mod, DOUBLE angle)
 {
-       SUFFIX(go_complex_init) (dst, mod * SUFFIX(cos) (angle), mod * SUFFIX(sin) (angle));
+       SUFFIX(go_complex_init) (dst,
+                                mod * SUFFIX(cos) (angle),
+                                mod * SUFFIX(sin) (angle));
 }
 
 static  void
 SUFFIX(go_complex_from_polar_pi) (COMPLEX *dst, DOUBLE mod, DOUBLE angle)
 {
-       DOUBLE s, c;
-       gboolean neg;
-
-       if (SUFFIX(fabs) (angle) >= 1) {
-               angle = SUFFIX(fmod) (angle, 2);
-               if (angle > 1)
-                       angle -= 2;
-               else if (angle <= -1)
-                       angle += 2;             
-       }
-
-       neg = (angle < 0);  /* Ignores -0 */
-       angle = SUFFIX(fabs) (angle);
-
-       if (angle == 0)
-               s = 0, c = 1;
-       else if (angle == 0.25)
-               s = c = SUFFIX(sqrt) (0.5);
-       else if (angle == 0.5)
-               s = 1, c = 0;
-       else if (angle == 0.75)
-               s = SUFFIX(sqrt) (0.5), c = -s;
-       else if (angle == 1)
-               s = 0, c = -1;
-       else {
-               s = SUFFIX(sin) (angle * M_PIgo);
-               c = SUFFIX(cos) (angle * M_PIgo);
-       }
-
-       if (neg)
-               s = -s;
-
-       SUFFIX(go_complex_init) (dst, mod * c, mod * s);
+       SUFFIX(go_complex_init) (dst,
+                                mod * SUFFIX(go_cospi) (angle),
+                                mod * SUFFIX(go_sinpi) (angle));
 }
 
 /* ------------------------------------------------------------------------- */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]