]> granicus.if.org Git - graphviz/commitdiff
consolidate PI into M_PI
authorellson <devnull@localhost>
Mon, 3 Mar 2008 23:01:51 +0000 (23:01 +0000)
committerellson <devnull@localhost>
Mon, 3 Mar 2008 23:01:51 +0000 (23:01 +0000)
lib/common/arith.h
lib/common/output.c
lib/common/shapes.c
lib/common/splines.c
lib/dotgen/dotsplines.c

index d51866a1cf31c0c76eb5304a1b39737791c85c47..2bf100e31c815c76b9a0f0c4d3c677aa6184f94b 100644 (file)
@@ -81,12 +81,12 @@ extern "C" {
 #define M_PI           3.14159265358979323846
 #endif
 
-#ifndef PI
-#define PI             M_PI
+#ifndef SQRT2
+#define SQRT2          1.41421356237309504880
 #endif
 
 #define ROUND(f)        ((f>=0)?(int)(f + .5):(int)(f - .5))
-#define RADIANS(deg)   ((deg)/180.0 * PI)
+#define RADIANS(deg)   ((deg)/180.0 * M_PI)
 #define DEGREES(rad)   ((rad)/M_PI * 180.0)
 
 #define SQR(a) ((a) * (a))
index fa9604abfba04855c0f5243610a4044c265b954b..fdf13c5806e4e7725a16bcd5a1f9d87655a7be20 100644 (file)
@@ -237,9 +237,9 @@ void attach_attrs_and_arrows(graph_t* g, int* sp, int* ep)
                        sprintf(buf, "%.3f %.3f",
                                ND_width(n) / 2.0 * cos(i /
                                                        (double) sides *
-                                                       PI * 2.0),
+                                                       M_PI * 2.0),
                                YFDIR(ND_height(n) / 2.0 *
-                                  sin(i / (double) sides * PI * 2.0)));
+                                  sin(i / (double) sides * M_PI * 2.0)));
                    agxbput(&xb, buf);
                }
                agxset(n, N_vertices->index, agxbuse(&xb));
index 60faf8246e5675a2e9fce53f44d7b6636b0e4570..23a302a4c4aa3ce8602e64a767954e9e30b6dd68 100644 (file)
@@ -840,7 +840,7 @@ static void poly_init(node_t * n)
     } else {
        /* for all other polygon shapes, compute the inner ellipse
           and then pad for that  */
-       temp = cos(PI / sides);
+       temp = cos(M_PI / sides);
        dimen.x /= temp;
        dimen.y /= temp;
        /* add padding based on the smaller radii */
@@ -907,21 +907,18 @@ static void poly_init(node_t * n)
            bb.y = 2. * P.y;
        }
     } else {
-
-# define SQRT2 1.41421356237
-
        vertices = N_NEW(outp * sides, pointf);
-       sectorangle = 2. * PI / sides;
+       sectorangle = 2. * M_PI / sides;
        sidelength = sin(sectorangle / 2.);
        skewdist = hypot(fabs(distortion) + fabs(skew), 1.);
        gdistortion = distortion * SQRT2 / cos(sectorangle / 2.);
        gskew = skew / 2.;
-       angle = (sectorangle - PI) / 2.;
+       angle = (sectorangle - M_PI) / 2.;
        sincos(angle, &sinx, &cosx);
        R.x = .5 * cosx;
        R.y = .5 * sinx;
        xmax = ymax = 0.;
-       angle += (PI - sectorangle) / 2.;
+       angle += (M_PI - sectorangle) / 2.;
        for (i = 0; i < sides; i++) {
 
            /*next regular vertex */
@@ -980,7 +977,7 @@ static void poly_init(node_t * n)
                R = vertices[(i + 1) % sides];
                alpha = beta;
                beta = atan2(R.y - Q.y, R.x - Q.x);
-               gamma = (alpha + PI - beta) / 2.;
+               gamma = (alpha + M_PI - beta) / 2.;
 
                /*find distance along bisector to */
                /*intersection of next periphery */
@@ -1205,24 +1202,24 @@ static double invflip_angle (double angle, int rankdir)
        angle *= -1; 
        break;
     case RANKDIR_LR:
-       angle -= PI * 0.5;
+       angle -= M_PI * 0.5;
        break;
     case RANKDIR_RL:
-       if (angle == PI)
-           angle = -0.5 * PI;
-       else if (angle == PI * 0.75)
-           angle = -0.25 * PI;
-       else if (angle == PI * 0.5)
+       if (angle == M_PI)
+           angle = -0.5 * M_PI;
+       else if (angle == M_PI * 0.75)
+           angle = -0.25 * M_PI;
+       else if (angle == M_PI * 0.5)
            angle = 0;
-       else if (angle == PI * 0.25)
+       else if (angle == M_PI * 0.25)
            angle = angle;
        else if (angle == 0)
-           angle = PI * 0.5;
-       else if (angle == PI * -0.25)
-           angle = PI * 0.75;
-       else if (angle == PI * -0.5)
-           angle = PI;
-       else if (angle == PI * -0.75)
+           angle = M_PI * 0.5;
+       else if (angle == M_PI * -0.25)
+           angle = M_PI * 0.75;
+       else if (angle == M_PI * -0.5)
+           angle = M_PI;
+       else if (angle == M_PI * -0.75)
            angle = angle;
        break;
     }
@@ -1322,19 +1319,19 @@ compassPort(node_t* n, box* bp, port* pp, char* compass, int sides, inside_t* ic
            clip = FALSE;
            switch (*compass) {
            case '\0':
-               theta = -PI * 0.5;
+               theta = -M_PI * 0.5;
                defined = TRUE;
                side = sides & BOTTOM;
                break;
            case 'e':
-               theta = -PI * 0.25;
+               theta = -M_PI * 0.25;
                defined = TRUE;
                if (ictxt) p = compassPoint (ictxt, -INT_MAX, INT_MAX);
                else p.x = b.UR.x;
                side = sides & (BOTTOM | RIGHT);
                break;
            case 'w':
-               theta = -PI * 0.75;
+               theta = -M_PI * 0.75;
                defined = TRUE;
                if (ictxt) p = compassPoint (ictxt, -INT_MAX, -INT_MAX);
                else p.x = b.LL.x;
@@ -1350,7 +1347,7 @@ compassPort(node_t* n, box* bp, port* pp, char* compass, int sides, inside_t* ic
            break;
        case 'w':
            p.x = b.LL.x;
-           theta = PI;
+           theta = M_PI;
            constrain = TRUE;
            defined = TRUE;
            clip = FALSE;
@@ -1363,19 +1360,19 @@ compassPort(node_t* n, box* bp, port* pp, char* compass, int sides, inside_t* ic
            switch (*compass) {
            case '\0':
                defined = TRUE;
-               theta = PI * 0.5;
+               theta = M_PI * 0.5;
                side = sides & TOP;
                break;
            case 'e':
                defined = TRUE;
-               theta = PI * 0.25;
+               theta = M_PI * 0.25;
                if (ictxt) p = compassPoint (ictxt, INT_MAX, INT_MAX);
                else p.x = b.UR.x;
                side = sides & (TOP | RIGHT);
                break;
            case 'w':
                defined = TRUE;
-               theta = PI * 0.75;
+               theta = M_PI * 0.75;
                if (ictxt) p = compassPoint (ictxt, INT_MAX, -INT_MAX);
                else p.x = b.LL.x;
                side = sides & (TOP | LEFT);
@@ -1402,9 +1399,9 @@ compassPort(node_t* n, box* bp, port* pp, char* compass, int sides, inside_t* ic
        pp->order = MC_SCALE/2;
     else {
        /* compute angle with 0 at north pole, increasing CCW */
-       double angle = atan2(p.y,p.x) + 1.5*PI;
-       if (angle >= 2*PI) angle -= 2*PI;
-       pp->order = (int)((MC_SCALE * angle) / (2*PI));
+       double angle = atan2(p.y,p.x) + 1.5*M_PI;
+       if (angle >= 2*M_PI) angle -= 2*M_PI;
+       pp->order = (int)((MC_SCALE * angle) / (2*M_PI));
     }
     pp->constrained = constrain;
     pp->defined = defined;
index efce2459db379aac5a4e7b98b0804de0224a02cf..4703e0a19940d27cf93114ee3655017a619809f5 100644 (file)
@@ -403,7 +403,7 @@ beginpath(path * P, edge_t * e, int et, pathend_t * endp, boolean merge)
     P->start.p = add_points(ND_coord_i(n), ED_tail_port(e).p);
     P->ulpp = P->urpp = P->llpp = P->lrpp = NULL;
     if (merge) {
-       /*P->start.theta = - PI / 2; */
+       /*P->start.theta = - M_PI / 2; */
        P->start.theta = conc_slope(e->tail);
        P->start.constrained = TRUE;
     } else {
@@ -592,9 +592,9 @@ void endpath(path * P, edge_t * e, int et, pathend_t * endp, boolean merge)
        pboxfn = NULL;
     P->end.p = add_points(ND_coord_i(n), ED_head_port(e).p);
     if (merge) {
-       /*P->end.theta = PI / 2; */
-       P->end.theta = conc_slope(e->head) + PI;
-       assert(P->end.theta < 2 * PI);
+       /*P->end.theta = M_PI / 2; */
+       P->end.theta = conc_slope(e->head) + M_PI;
+       assert(P->end.theta < 2 * M_PI);
        P->end.constrained = TRUE;
     } else {
        if (ED_head_port(e).constrained) {
index 709a2e65e7f47a2204e2333ca8a8fe6eabf477a9..1385c22ceed6231a9f5ccb65a7d6d46288e657b4 100644 (file)
@@ -1420,7 +1420,7 @@ make_regular_edge(spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt
                       ND_coord_i(hn).y + GD_rank(hn->graph)[ND_rank(hn)].ht2);
            if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
                hend.boxes[hend.boxn++] = b;
-           P->end.theta = PI / 2, P->end.constrained = TRUE;
+           P->end.theta = M_PI / 2, P->end.constrained = TRUE;
            completeregularpath(P, segfirst, e, &tend, &hend, boxes, boxn, 1);
            if (splines) ps = routesplines(P, &pn);
            else {
@@ -1447,7 +1447,7 @@ make_regular_edge(spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt
                       ND_coord_i(tn).y - GD_rank(tn->graph)[ND_rank(tn)].ht1);
            if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
                tend.boxes[tend.boxn++] = b;
-           P->start.theta = -PI / 2, P->start.constrained = TRUE;
+           P->start.theta = -M_PI / 2, P->start.constrained = TRUE;
            smode = FALSE;
        }
        boxes[boxn++] = rank_box(sp, g, ND_rank(tn));