From 40ce41feb9f90d1d27661cf3e90ee0922feacbd3 Mon Sep 17 00:00:00 2001 From: erg Date: Fri, 13 Jun 2008 17:12:57 +0000 Subject: [PATCH] Make various geometry routines such as subPt available globally; modify old Voronoi code to use common pointf type; rename subPt in Voronoi code to avoid conflict. --- lib/common/geom.c | 6 +++--- lib/common/geomprocs.h | 3 +++ lib/neatogen/geometry.c | 2 +- lib/neatogen/geometry.h | 6 +++++- lib/neatogen/poly.c | 4 ++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/common/geom.c b/lib/common/geom.c index f0106386f..b1e09f0f9 100644 --- a/lib/common/geom.c +++ b/lib/common/geom.c @@ -534,7 +534,7 @@ double ptToLine2 (pointf a, pointf b, pointf p) #define SMALL 0.0000000001 -static pointf +pointf subPt (pointf a, pointf b) { pointf c; @@ -544,7 +544,7 @@ subPt (pointf a, pointf b) return c; } -static pointf +pointf perp (pointf a) { pointf c; @@ -560,7 +560,7 @@ dot (pointf a, pointf b) return (a.x*b.x + a.y*b.y); } -static pointf +pointf scale (double c, pointf a) { pointf b; diff --git a/lib/common/geomprocs.h b/lib/common/geomprocs.h index 617f780e9..6b0a57475 100644 --- a/lib/common/geomprocs.h +++ b/lib/common/geomprocs.h @@ -72,6 +72,9 @@ extern point cwrotatep(point p, int cwrot); extern pointf cwrotatepf(pointf p, int cwrot); extern void rect2poly(pointf *p); +extern pointf scale(double c, pointf v); +extern pointf perp(pointf v); +extern pointf subPt(pointf v, pointf w); extern int seg_intersect (pointf a, pointf b, pointf c, pointf d, pointf* x); #ifdef __cplusplus diff --git a/lib/neatogen/geometry.c b/lib/neatogen/geometry.c index 126af3449..19ce6c14c 100644 --- a/lib/neatogen/geometry.c +++ b/lib/neatogen/geometry.c @@ -45,7 +45,7 @@ double dist_2(Point * pp, Point * qp) return (dx * dx + dy * dy); } -void subPt(Point * a, Point b, Point c) +void subpt(Point * a, Point b, Point c) { a->x = b.x - c.x; a->y = b.y - c.y; diff --git a/lib/neatogen/geometry.h b/lib/neatogen/geometry.h index 19778b337..345ed017c 100644 --- a/lib/neatogen/geometry.h +++ b/lib/neatogen/geometry.h @@ -23,9 +23,13 @@ extern "C" { #ifndef GEOMETRY_H #define GEOMETRY_H +#ifdef HAVE_POINTF_S + typedef pointf Point; +#else typedef struct Point { double x, y; } Point; +#endif extern Point origin; @@ -37,7 +41,7 @@ extern "C" { extern void geominit(void); extern double dist_2(Point *, Point *); /* Distance squared between two points */ - extern void subPt(Point * a, Point b, Point c); + extern void subpt(Point * a, Point b, Point c); extern void addPt(Point * a, Point b, Point c); extern double area_2(Point a, Point b, Point c); extern int leftOf(Point a, Point b, Point c); diff --git a/lib/neatogen/poly.c b/lib/neatogen/poly.c index 3c93f8495..3d3c21546 100644 --- a/lib/neatogen/poly.c +++ b/lib/neatogen/poly.c @@ -384,8 +384,8 @@ static int edgesIntersect(Point * P, Point * Q, int n, int m) a1 = (a + n - 1) % n; b1 = (b + m - 1) % m; - subPt(&A, P[a], P[a1]); - subPt(&B, Q[b], Q[b1]); + subpt(&A, P[a], P[a1]); + subpt(&B, Q[b], Q[b1]); cross = area_2(origin, A, B); bHA = leftOf(P[a1], P[a], Q[b]); -- 2.40.0