From: ellson Date: Tue, 1 Feb 2005 22:31:32 +0000 (+0000) Subject: use P2PF and PF2P macros X-Git-Tag: LAST_LIBGRAPH~32^2~7956 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39c8c99c7b9b1b7766c150dc39f4892594c9dd28;p=graphviz use P2PF and PF2P macros --- diff --git a/lib/common/utils.c b/lib/common/utils.c index d2f67f910..64c5efd57 100644 --- a/lib/common/utils.c +++ b/lib/common/utils.c @@ -24,9 +24,6 @@ #endif -/* local funcs */ -static double dist2(pointf, pointf); - void *zmalloc(size_t nbytes) { char *rv = malloc(nbytes); @@ -633,10 +630,10 @@ int mapbool(char *p) return atoi(p); } -static double dist2(p, q) /* return square of dist between p and q */ -pointf p, q; +static double dist2(pointf p, pointf q) /* return square of dist between p and q */ { double d0, d1; + d0 = p.x - q.x; d1 = p.y - q.y; return (d0 * d0 + d1 * d1); @@ -645,7 +642,7 @@ pointf p, q; point dotneato_closest(splines * spl, point p) { int i, j, k, besti, bestj; - double bestdist2, d2, dlow2, dhigh2; + double bestdist2, d2, dlow2, dhigh2; /* squares of distances */ double low, high, t; pointf c[4], pt2, pt; point rv; @@ -653,8 +650,7 @@ point dotneato_closest(splines * spl, point p) besti = bestj = -1; bestdist2 = 1e+38; - pt.x = p.x; - pt.y = p.y; + P2PF(p, pt); for (i = 0; i < spl->size; i++) { bz = spl->list[i]; for (j = 0; j < bz.size; j++) { @@ -698,8 +694,7 @@ point dotneato_closest(splines * spl, point p) dlow2 = dist2(pt2, pt); } } while (1); - rv.x = pt2.x; - rv.y = pt2.y; + PF2P(pt2, rv); return rv; } diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index 2f8ac917e..a702bcd12 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -87,10 +87,6 @@ static void completeflatpath(path *, pathend_t *, pathend_t *, int, int, int, int, int, box *, box *, int, int); static void completeregularpath(path *, Agedge_t *, Agedge_t *, pathend_t *, pathend_t *, box *, int, int); -#if 0 -static double dist(pointf, pointf); -#endif -static double dist2(pointf, pointf); static int edgecmp(Agedge_t **, Agedge_t **); static Agedge_t *getmainedge(Agedge_t *); static box makeflatcomponent(box, box, int, int, int, int, int); @@ -1328,30 +1324,19 @@ static edge_t *bot_bound(edge_t * e, int side) return ans; } -static double dist2(p, q) /* square of scalar distance between p and q */ -pointf p, q; +static double dist2(pointf p, pointf q) /* square of distance between p and q */ { double d0, d1; - d0 = p.x - q.x; - d1 = p.y - q.y; - return (d0 * d0 + d1 * d1); -} -#if 0 -static double dist(p, q) /* scalar distance between p and q */ -pointf p, q; -{ - double d0, d1; d0 = p.x - q.x; d1 = p.y - q.y; - return sqrt(d0 * d0 + d1 * d1); + return (d0 * d0 + d1 * d1); } -#endif point closest(splines * spl, point p) { int i, j, k, besti, bestj; - double bestdist2, d2, dlow2, dhigh2; + double bestdist2, d2, dlow2, dhigh2; /* squares of distance */ double low, high, t; pointf c[4], pt2, pt; point rv; @@ -1359,8 +1344,7 @@ point closest(splines * spl, point p) besti = bestj = -1; bestdist2 = 1e+38; - pt.x = p.x; - pt.y = p.y; + P2PF(p, pt); for (i = 0; i < spl->size; i++) { bz = spl->list[i]; for (j = 0; j < bz.size; j++) { @@ -1404,8 +1388,7 @@ point closest(splines * spl, point p) dlow2 = dist2(pt2, pt); } } while (1); - rv.x = pt2.x; - rv.y = pt2.y; + PF2P(pt2, rv); return rv; }