40 #include "libavoid/assertions.h"
45 extern double euclideanDist(
const Point& a,
const Point& b);
46 extern double manhattanDist(
const Point& a,
const Point& b);
47 extern double totalLength(
const Polygon& poly);
48 extern double angle(
const Point& a,
const Point& b,
const Point& c);
49 extern bool segmentIntersect(
const Point& a,
const Point& b,
50 const Point& c,
const Point& d);
51 extern bool segmentShapeIntersect(
const Point& e1,
const Point& e2,
52 const Point& s1,
const Point& s2,
bool& seenIntersectionAtEndpoint);
53 extern bool inPoly(
const Polygon& poly,
const Point& q,
bool countBorder =
true);
54 extern bool inPolyGen(
const PolygonInterface& poly,
const Point& q);
55 extern bool inValidRegion(
bool IgnoreRegions,
const Point& a0,
56 const Point& a1,
const Point& a2,
const Point& b);
57 extern int cornerSide(
const Point &c1,
const Point &c2,
const Point &c3,
59 extern bool pointOnLine(
const Point& a,
const Point& b,
const Point& c,
60 const double tolerance = 0.0);
63 extern bool inBetween(
const Point& a,
const Point& b,
const Point& c);
78 static inline int vecDir(
const Point& a,
const Point& b,
const Point& c,
79 const double maybeZero = 0.0)
81 COLA_ASSERT(maybeZero >= 0);
83 double area2 = ((b.x - a.x) * (c.y - a.y)) -
84 ((c.x - a.x) * (b.y - a.y));
86 if (area2 < (-maybeZero))
90 else if (area2 > maybeZero)
98 static inline Point projection(
const Point& a,
const Point& b,
const Point& c)
100 double ux = c.
x - a.x,
104 scalarProj = ux * vx + uy * vy;
105 scalarProj /= ux * ux + uy * uy;
107 p.x = scalarProj * ux + a.x;
108 p.y = scalarProj * uy + a.y;
115 static const int DONT_INTERSECT = 0;
116 static const int DO_INTERSECT = 1;
117 static const int PARALLEL = 3;
118 extern int segmentIntersectPoint(
const Point& a1,
const Point& a2,
119 const Point& b1,
const Point& b2,
double *x,
double *y);
120 extern int rayIntersectPoint(
const Point& a1,
const Point& a2,
121 const Point& b1,
const Point& b2,
double *x,
double *y);
122 extern double rotationalAngle(
const Point& p);