]> granicus.if.org Git - graphviz/commitdiff
more header cleanup, add generalized point-around-origin rotations
authorellson <devnull@localhost>
Tue, 18 Oct 2005 18:58:22 +0000 (18:58 +0000)
committerellson <devnull@localhost>
Tue, 18 Oct 2005 18:58:22 +0000 (18:58 +0000)
lib/common/args.c
lib/common/diagen.c
lib/common/figgen.c
lib/common/geom.c
lib/common/htmlparse.y
lib/common/memory.c
lib/common/psusershape.c
lib/common/utils.c
lib/gvc/gvconfig.c
lib/gvc/gvcontext.c

index 4882af4fb2b614f3dc46c9565923c761f1768b92..88572e7bf80903db39df0e137fd65c57b84e74a4 100644 (file)
  * Needs to be fixed before layout engines can be plugins.
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #include "render.h"
 #include "tlayout.h"
 
index 5e0a33ba0fd0537e87b744b1d6503453429c2549..b7c31c0ec2150bc287b8662a373b1d8503b367a3 100644 (file)
 
 
 
-#include <stdarg.h>
-
 #include "render.h"
 
+#include <stdarg.h>
 #ifdef HAVE_LIBZ
 #include <zlib.h>
 #ifdef MSWIN32
index 66bbdbad737a555f526ad308d0473c726f7c690e..2a2676b30f1993285deab5b284c8b716b9507e6c 100644 (file)
@@ -15,7 +15,6 @@
 **********************************************************/
 
 #include <ctype.h>
-
 #include "render.h"
 
 /* FIG font modifiers */
index c9d6eff2f50195e927a5ff68695594768d090492..e39cf6f33c3da45893d2e8d06f977d055000f98b 100644 (file)
 /* geometric functions (e.g. on points and boxes) with application to, but
  * no specific dependance on graphs */
 
-#include <stdio.h>
 #include "geom.h"
-#include "types.h"
-#include "graph.h"
 #include "geomprocs.h"
-#include "types.h"
-#include "graph.h"
 
 point pointof(int x, int y)
 {
@@ -354,15 +349,40 @@ int lineToBox(pointf p1, pointf p2, boxf b)
     return -1;
 }
 
-point ccwrotatep(point p, int ccwrot)
+static pointf rotatepf(pointf p, int cwrot)
+{
+    static double sina, cosa;
+    static int last_cwrot;
+    pointf P;
+
+    if (cwrot != last_cwrot) {
+       sincos(cwrot / (2 * M_PI), &sina, &cosa);
+       last_cwrot = cwrot;
+    }
+    P.x = p.x * cosa - p.y * sina;
+    P.y = p.y * cosa + p.x * sina;
+    return P;
+}
+
+static point rotatep(point p, int cwrot)
+{
+    pointf pf;
+
+    P2PF(p, pf);
+    pf = rotatepf(pf, cwrot);
+    PF2P(pf, p);
+    return p;
+}
+
+point cwrotatep(point p, int cwrot)
 {
     int x = p.x, y = p.y;
-    switch (ccwrot) {
+    switch (cwrot) {
     case 0:
        break;
     case 90:
-       p.x = -y;
-       p.y = x;
+       p.x = y;
+       p.y = -x;
        break;
     case 180:
        p.x = x;
@@ -373,20 +393,24 @@ point ccwrotatep(point p, int ccwrot)
        p.y = x;
        break;
     default:
-       agerr (AGWARN, "unsupported ccw rotation: %d degrees\n", ccwrot);
+       if (cwrot < 0)
+           return ccwrotatep(p, -cwrot);
+        if (cwrot > 360)
+           return cwrotatep(p, cwrot%360);
+       return rotatep(p, cwrot);
     }
     return p;
 }
 
-pointf ccwrotatepf(pointf p, int ccwrot)
+pointf cwrotatepf(pointf p, int cwrot)
 {
     double x = p.x, y = p.y;
-    switch (ccwrot) {
+    switch (cwrot) {
     case 0:
        break;
     case 90:
-       p.x = -y;
-       p.y = x;
+       p.x = y;
+       p.y = -x;
        break;
     case 180:
        p.x = x;
@@ -397,20 +421,24 @@ pointf ccwrotatepf(pointf p, int ccwrot)
        p.y = x;
        break;
     default:
-       agerr (AGWARN, "unsupported ccw rotation: %d degrees\n", ccwrot);
+       if (cwrot < 0)
+           return ccwrotatepf(p, -cwrot);
+        if (cwrot > 360)
+           return cwrotatepf(p, cwrot%360);
+       return rotatepf(p, cwrot);
     }
     return p;
 }
 
-point cwrotatep(point p, int cwrot)
+point ccwrotatep(point p, int ccwrot)
 {
     int x = p.x, y = p.y;
-    switch (cwrot) {
+    switch (ccwrot) {
     case 0:
        break;
     case 90:
-       p.x = y;
-       p.y = -x;
+       p.x = -y;
+       p.y = x;
        break;
     case 180:
        p.x = x;
@@ -421,20 +449,24 @@ point cwrotatep(point p, int cwrot)
        p.y = x;
        break;
     default:
-       agerr (AGWARN, "unsupported cw rotation: %d degrees\n", cwrot);
+       if (ccwrot < 0)
+           return cwrotatep(p, -ccwrot);
+        if (ccwrot > 360)
+           return ccwrotatep(p, ccwrot%360);
+       return rotatep(p, 360-ccwrot);
     }
     return p;
 }
 
-pointf cwrotatepf(pointf p, int cwrot)
+pointf ccwrotatepf(pointf p, int ccwrot)
 {
     double x = p.x, y = p.y;
-    switch (cwrot) {
+    switch (ccwrot) {
     case 0:
        break;
     case 90:
-       p.x = y;
-       p.y = -x;
+       p.x = -y;
+       p.y = x;
        break;
     case 180:
        p.x = x;
@@ -445,7 +477,11 @@ pointf cwrotatepf(pointf p, int cwrot)
        p.y = x;
        break;
     default:
-       agerr (AGWARN, "unsupported cw rotation: %d degrees\n", cwrot);
+       if (ccwrot < 0)
+           return cwrotatepf(p, -ccwrot);
+        if (ccwrot > 360)
+           return ccwrotatepf(p, ccwrot%360);
+       return rotatepf(p, 360-ccwrot);
     }
     return p;
 }
index 8b8bd41536fd779a2b2c7577dcf05af757a94e19..c2e65a742262b36fc1fc69296a0f4a5d30e6da9f 100644 (file)
@@ -17,9 +17,6 @@
 %{
 
 #include "render.h"
-#include "gvplugin.h"
-#include "gvcint.h"
-#include "gvcproc.h"
 #include "htmltable.h"
 #include "htmllex.h"
 
index b060e29417bf025bba5860e0e1995a7478962c9a..a1d24f40e4cbbb30635d4f5f60a6476dd16cbe8b 100644 (file)
@@ -20,8 +20,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <stdlib.h>
-
 #include "memory.h"
 
 void *zmalloc(size_t nbytes)
index fa8ff968565874b0507b97b8e0a85480b019f17c..b85303ccf54a5143ac364dbffc1b2ef576f14fbd 100644 (file)
@@ -19,8 +19,6 @@
 #endif
 
 #include <sys/stat.h>
-#include <stdio.h>
-
 #include "render.h"
 
 static int N_EPSF_files;
index c3fd9e141cd9095c73ad0c2558bc624b50853d0a..bdaa6d822566e342578ad7f6edc933b8503454eb 100644 (file)
 *              AT&T Research, Florham Park NJ             *
 **********************************************************/
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#include "render.h"
+#include "agxbuf.h"
+#include "htmltable.h"
 
 #ifndef MSWIN32
 #include <unistd.h>
 #endif
 
-#include "render.h"
-#include "agxbuf.h"
-#include "htmltable.h"
-
 /*
  *  a queue of nodes
  */
index 1739a57a28f5130c3e944a3bdfd79f8d5d2572c5..b867ea21ce03240da603d705dda77da76a6eb023 100644 (file)
 #include "config.h"
 #endif
 
-#include       <stdio.h>
-#include       <stdlib.h>
 #include       <string.h>
 
 #ifndef DISABLE_LTDL
-#include       <sys/types.h>
 #include       <regex.h>
 #include       <sys/stat.h>
 #include       <unistd.h>
 #include       <glob.h>
 #endif
 
-#include        "geom.h"
-#include        "color.h"
 #include        "memory.h"
 
 #include        "const.h"
index ae732d6dfe40ea3d55bfb008e092e6805dffbe11..c434e65d231ade9049621399ef8d895103c9ae63 100644 (file)
 #include "config.h"
 #endif
 
-#include        <stdio.h>
-#include        <stdlib.h>
-
-#include       "geom.h"
-
 #include       "types.h"
 #include       "graph.h"
-
 #include        "gvplugin.h"
 #include        "gvcint.h"
 #include        "gvcproc.h"