#include "geom.h"
#include "geomprocs.h"
-inline point pointof(int x, int y)
-{
- point r;
-
- r.x = x;
- r.y = y;
- return r;
-}
-
-inline pointf pointfof(double x, double y)
-{
- pointf r;
-
- r.x = x;
- r.y = y;
- return r;
-}
-
-inline box boxof(int llx, int lly, int urx, int ury)
-{
- box b;
-
- b.LL.x = llx, b.LL.y = lly;
- b.UR.x = urx, b.UR.y = ury;
- return b;
-}
-
-inline boxf boxfof(double llx, double lly, double urx, double ury)
-{
- boxf b;
-
- b.LL.x = llx, b.LL.y = lly;
- b.UR.x = urx, b.UR.y = ury;
- return b;
-}
-
box mkbox(point p, point q)
{
box r;
return r;
}
-inline point add_point(point p, point q)
-{
- point r;
-
- r.x = p.x + q.x;
- r.y = p.y + q.y;
- return r;
-}
-
-inline pointf add_pointf(pointf p, pointf q)
-{
- pointf r;
-
- r.x = p.x + q.x;
- r.y = p.y + q.y;
- return r;
-}
-
-inline point sub_point(point p, point q)
-{
- point r;
-
- r.x = p.x - q.x;
- r.y = p.y - q.y;
- return r;
-}
-
-inline pointf sub_pointf(pointf p, pointf q)
-{
- pointf r;
-
- r.x = p.x - q.x;
- r.y = p.y - q.y;
- return r;
-}
-
-/* for +ve coord values, this rounds towards p */
-inline point mid_point(point p, point q)
-{
- point r;
-
- r.x = (p.x + q.x) / 2;
- r.y = (p.y + q.y) / 2;
- return r;
-}
-
-inline pointf mid_pointf(pointf p, pointf q)
-{
- pointf r;
-
- r.x = (p.x + q.x) / 2.;
- r.y = (p.y + q.y) / 2.;
- return r;
-}
-
-inline pointf interpolate_pointf(double t, pointf p, pointf q)
-{
- pointf r;
-
- r.x = p.x + t * (q.x - p.x);
- r.y = p.y + t * (q.y - p.y);
- return r;
-}
-
-inline point exch_xy(point p)
-{
- point r;
-
- r.x = p.y;
- r.y = p.x;
- return r;
-}
-
-inline pointf exch_xyf(pointf p)
-{
- pointf r;
-
- r.x = p.y;
- r.y = p.x;
- return r;
-}
-
-inline box box_bb(box b0, box b1)
-{
- box b;
-
- b.LL.x = MIN(b0.LL.x, b1.LL.x);
- b.LL.y = MIN(b0.LL.y, b1.LL.y);
- b.UR.x = MAX(b0.UR.x, b1.UR.x);
- b.UR.y = MAX(b0.UR.y, b1.UR.y);
-
- return b;
-}
-
-inline boxf boxf_bb(boxf b0, boxf b1)
-{
- boxf b;
-
- b.LL.x = MIN(b0.LL.x, b1.LL.x);
- b.LL.y = MIN(b0.LL.y, b1.LL.y);
- b.UR.x = MAX(b0.UR.x, b1.UR.x);
- b.UR.y = MAX(b0.UR.y, b1.UR.y);
-
- return b;
-}
-
-inline box box_intersect(box b0, box b1)
-{
- box b;
-
- b.LL.x = MAX(b0.LL.x, b1.LL.x);
- b.LL.y = MAX(b0.LL.y, b1.LL.y);
- b.UR.x = MIN(b0.UR.x, b1.UR.x);
- b.UR.y = MIN(b0.UR.y, b1.UR.y);
-
- return b;
-}
-
-inline boxf boxf_intersect(boxf b0, boxf b1)
-{
- boxf b;
-
- b.LL.x = MAX(b0.LL.x, b1.LL.x);
- b.LL.y = MAX(b0.LL.y, b1.LL.y);
- b.UR.x = MIN(b0.UR.x, b1.UR.x);
- b.UR.y = MIN(b0.UR.y, b1.UR.y);
-
- return b;
-}
-
-inline int box_overlap(box b0, box b1)
-{
- return OVERLAP(b0, b1);
-}
-
-inline int boxf_overlap(boxf b0, boxf b1)
-{
- return OVERLAP(b0, b1);
-}
-
-inline int box_contains(box b0, box b1)
-{
- return CONTAINS(b0, b1);
-}
-
-inline int boxf_contains(boxf b0, boxf b1)
-{
- return CONTAINS(b0, b1);
-}
-
/*
*--------------------------------------------------------------
*
return a2 / (dx*dx + dy*dy);
}
-inline pointf perp (pointf p)
-{
- pointf r;
-
- r.x = -p.y;
- r.y = p.x;
- return r;
-}
-
#define dot(v,w) (v.x*w.x+v.y*w.y)
-inline pointf scale (double c, pointf p)
-{
- pointf r;
-
- r.x = c * p.x;
- r.y = c * p.y;
- return r;
-}
-
/* intersect:
* Computes intersection of lines a-b and c-d, returning intersection
* point in *p.
extern "C" {
#endif
-#include <geom.h>
-
-extern point pointof(int a, int b);
-extern pointf pointfof(double a, double b);
-
-extern point add_point(point p, point q);
-extern pointf add_pointf(pointf p, pointf q);
-
-extern point sub_point(point p, point q);
-extern pointf sub_pointf(pointf p, pointf q);
-
-extern point mid_point(point p, point q);
-extern pointf mid_pointf(pointf p, pointf q);
-
-extern pointf interpolate_pointf(double t, pointf p, pointf q);
-
-extern point exch_xy(point p);
-extern pointf exch_xyf(pointf p);
-
-extern box boxof(int llx, int lly, int urx, int ury);
-extern boxf boxfof(double llx, double lly, double urx, double ury);
+#include "geom.h"
extern box mkbox(point p, point q);
extern boxf mkboxf(pointf p, pointf q);
-extern box box_bb(box b0, box b1);
-extern boxf boxf_bb(boxf b0, boxf b1);
-
-extern box box_intersect(box b0, box b1);
-extern boxf boxf_intersect(boxf b0, boxf b1);
-
-extern int box_overlap(box b0, box b1);
-extern int boxf_overlap(boxf b0, boxf b1);
-
-extern int box_contains(box b0, box b1);
-extern int boxf_contains(boxf b0, boxf b1);
-
extern box flip_rec_box(box b, point p);
extern boxf flip_rec_boxf(boxf b, pointf p);
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 pointf addPt(pointf v, pointf w);
extern int seg_intersect (pointf a, pointf b, pointf c, pointf d, pointf* p);
+
+static inline point pointof(int x, int y)
+{
+ point r;
+
+ r.x = x;
+ r.y = y;
+ return r;
+}
+
+static inline pointf pointfof(double x, double y)
+{
+ pointf r;
+
+ r.x = x;
+ r.y = y;
+ return r;
+}
+
+static inline box boxof(int llx, int lly, int urx, int ury)
+{
+ box b;
+
+ b.LL.x = llx, b.LL.y = lly;
+ b.UR.x = urx, b.UR.y = ury;
+ return b;
+}
+
+static inline boxf boxfof(double llx, double lly, double urx, double ury)
+{
+ boxf b;
+
+ b.LL.x = llx, b.LL.y = lly;
+ b.UR.x = urx, b.UR.y = ury;
+ return b;
+}
+
+static inline point add_point(point p, point q)
+{
+ point r;
+
+ r.x = p.x + q.x;
+ r.y = p.y + q.y;
+ return r;
+}
+
+static inline pointf add_pointf(pointf p, pointf q)
+{
+ pointf r;
+
+ r.x = p.x + q.x;
+ r.y = p.y + q.y;
+ return r;
+}
+
+static inline point sub_point(point p, point q)
+{
+ point r;
+
+ r.x = p.x - q.x;
+ r.y = p.y - q.y;
+ return r;
+}
+
+static inline pointf sub_pointf(pointf p, pointf q)
+{
+ pointf r;
+
+ r.x = p.x - q.x;
+ r.y = p.y - q.y;
+ return r;
+}
+
+/* for +ve coord values, this rounds towards p */
+static inline point mid_point(point p, point q)
+{
+ point r;
+
+ r.x = (p.x + q.x) / 2;
+ r.y = (p.y + q.y) / 2;
+ return r;
+}
+
+static inline pointf mid_pointf(pointf p, pointf q)
+{
+ pointf r;
+
+ r.x = (p.x + q.x) / 2.;
+ r.y = (p.y + q.y) / 2.;
+ return r;
+}
+
+static inline pointf interpolate_pointf(double t, pointf p, pointf q)
+{
+ pointf r;
+
+ r.x = p.x + t * (q.x - p.x);
+ r.y = p.y + t * (q.y - p.y);
+ return r;
+}
+
+static inline point exch_xy(point p)
+{
+ point r;
+
+ r.x = p.y;
+ r.y = p.x;
+ return r;
+}
+
+static inline pointf exch_xyf(pointf p)
+{
+ pointf r;
+
+ r.x = p.y;
+ r.y = p.x;
+ return r;
+}
+
+static inline box box_bb(box b0, box b1)
+{
+ box b;
+
+ b.LL.x = MIN(b0.LL.x, b1.LL.x);
+ b.LL.y = MIN(b0.LL.y, b1.LL.y);
+ b.UR.x = MAX(b0.UR.x, b1.UR.x);
+ b.UR.y = MAX(b0.UR.y, b1.UR.y);
+
+ return b;
+}
+
+static inline boxf boxf_bb(boxf b0, boxf b1)
+{
+ boxf b;
+
+ b.LL.x = MIN(b0.LL.x, b1.LL.x);
+ b.LL.y = MIN(b0.LL.y, b1.LL.y);
+ b.UR.x = MAX(b0.UR.x, b1.UR.x);
+ b.UR.y = MAX(b0.UR.y, b1.UR.y);
+
+ return b;
+}
+
+static inline box box_intersect(box b0, box b1)
+{
+ box b;
+
+ b.LL.x = MAX(b0.LL.x, b1.LL.x);
+ b.LL.y = MAX(b0.LL.y, b1.LL.y);
+ b.UR.x = MIN(b0.UR.x, b1.UR.x);
+ b.UR.y = MIN(b0.UR.y, b1.UR.y);
+
+ return b;
+}
+
+static inline boxf boxf_intersect(boxf b0, boxf b1)
+{
+ boxf b;
+
+ b.LL.x = MAX(b0.LL.x, b1.LL.x);
+ b.LL.y = MAX(b0.LL.y, b1.LL.y);
+ b.UR.x = MIN(b0.UR.x, b1.UR.x);
+ b.UR.y = MIN(b0.UR.y, b1.UR.y);
+
+ return b;
+}
+
+static inline int box_overlap(box b0, box b1)
+{
+ return OVERLAP(b0, b1);
+}
+
+static inline int boxf_overlap(boxf b0, boxf b1)
+{
+ return OVERLAP(b0, b1);
+}
+
+static inline int box_contains(box b0, box b1)
+{
+ return CONTAINS(b0, b1);
+}
+
+static inline int boxf_contains(boxf b0, boxf b1)
+{
+ return CONTAINS(b0, b1);
+}
+
+static inline pointf perp (pointf p)
+{
+ pointf r;
+
+ r.x = -p.y;
+ r.y = p.x;
+ return r;
+}
+
+static inline pointf scale (double c, pointf p)
+{
+ pointf r;
+
+ r.x = c * p.x;
+ r.y = c * p.y;
+ return r;
+}
+
#ifdef __cplusplus
}
#endif