From: ellson Date: Mon, 3 Mar 2008 23:01:51 +0000 (+0000) Subject: consolidate PI into M_PI X-Git-Tag: LAST_LIBGRAPH~32^2~4596 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=219966a022d2ae5f7cbe8ee82a3ff30e70dfd7b4;p=graphviz consolidate PI into M_PI --- diff --git a/lib/common/arith.h b/lib/common/arith.h index d51866a1c..2bf100e31 100644 --- a/lib/common/arith.h +++ b/lib/common/arith.h @@ -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)) diff --git a/lib/common/output.c b/lib/common/output.c index fa9604abf..fdf13c580 100644 --- a/lib/common/output.c +++ b/lib/common/output.c @@ -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)); diff --git a/lib/common/shapes.c b/lib/common/shapes.c index 60faf8246..23a302a4c 100644 --- a/lib/common/shapes.c +++ b/lib/common/shapes.c @@ -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; diff --git a/lib/common/splines.c b/lib/common/splines.c index efce2459d..4703e0a19 100644 --- a/lib/common/splines.c +++ b/lib/common/splines.c @@ -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) { diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index 709a2e65e..1385c22ce 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -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));