27 size_t n = contour.size();
31 for (
size_t p = n - 1, q = 0; q < n; p = q++)
33 A += contour[p].x * contour[q].y - contour[q].x * contour[p].y;
46 float ax = NAN, ay = NAN, bx = NAN, by = NAN, cx = NAN, cy = NAN, apx = NAN, apy = NAN, bpx = NAN,
47 bpy = NAN, cpx = NAN, cpy = NAN;
48 float cCROSSap = NAN, bCROSScp = NAN, aCROSSbp = NAN;
63 aCROSSbp = ax * bpy - ay * bpx;
64 cCROSSap = cx * apy - cy * apx;
65 bCROSScp = bx * cpy - by * cpx;
67 return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
73 float Ax = NAN, Ay = NAN, Bx = NAN, By = NAN, Cx = NAN, Cy = NAN, Px = NAN, Py = NAN;
84 if (
EPSILON_6 > (((Bx - Ax) * (Cy - Ay)) - ((By - Ay) * (Cx - Ax))))
89 for (p = 0; p < n; p++)
91 if ((p == u) || (p == v) || (p == w))
110 size_t n = contour.size();
120 if (0.0f <
Area(contour))
121 for (
int v = 0; v < n; v++)
126 for (
int v = 0; v < n; v++)
128 V[v] = (
static_cast<int>(n) - 1) - v;
131 int nv =
static_cast<int>(n);
136 for (
int m = 0, v = nv - 1; nv > 2;)
162 if (
Snip(contour, u, v, w, nv, V))
164 int a = 0, b = 0,
c = 0,
s = 0, t = 0;
172 result.push_back(contour[a]);
173 result.push_back(contour[b]);
174 result.push_back(contour[
c]);
179 for (
s = v, t = v + 1; t < nv;
s++, t++)
std::vector< vec2 > Vector2dVector
static bool InsideTriangle(float Ax, float Ay, float Bx, float By, float Cx, float Cy, float Px, float Py)
Decide if the point (Px,Py) is inside a triangle defined by three points (Ax,Ay) (Bx,...
static float Area(const Vector2dVector &contour)
Compute and return area of a contour/polygon.
static bool Snip(const Vector2dVector &contour, int u, int v, int w, int n, int *V)
static bool Process(const Vector2dVector &contour, Vector2dVector &result)
Triangulate a contour/polygon, places results in STL vector as series of triangles.