16 for (
unsigned int i = 0; i < size; ++ i) {
17 unsigned int iPlusOne = (i + 1) % size;
21 sum += edge[0] * edge[1];
23 if (
sum <= 0.0)
return;
33 unsigned int iPlusOne = (i + 1) % numVertices;
34 unsigned int iMinusOne = (i + numVertices - 1) % numVertices;
39 double vectorProduct = edge0[0] * edge1[1] - edge0[1] * edge1[0];
41 return (vectorProduct < 0.0);
46 return a[0] * b[1] -
a[1] * b[0];
72 unsigned int l)
const {
81 if (numVertices < 5)
return false;
84 unsigned int iPlusOne = (i + 1) % numVertices;
85 unsigned int iMinusOne = (i + numVertices - 1) % numVertices;
92 for (
unsigned int j = iPlusOne + 1; j < iPlusOne + numVertices - 3; ++ j) {
93 unsigned int k = (j % numVertices);
94 unsigned int kPlusOne = ((k + 1) % numVertices);
105 iPlusOne, iMinusOne))
117 double angle =
std::acos((
a[0] * b[0] +
a[1] * b[1]) / lengthA / lengthB);
118 if (
a[0] * b[1] -
a[1] * b[0] < 0.0)
130 return edge0[0] * edge1[0] + edge0[1] * edge1[1];
135 return a[0] * b[0] +
a[1] * b[1];
140 unsigned int jPlusOne,
141 unsigned int jMinusOne)
const {
153 unsigned int iMinusTwo = (i + size - 2) % size;
154 unsigned int iMinusOne = (i + size - 1) % size;
155 unsigned int iPlusOne = (i + 1) % size;
156 unsigned int iPlusTwo = (i + 2) % size;
171 std::vector<unsigned int> ears;
173 for (
unsigned int i = 0; i < size; ++ i) {
184 unsigned int previous = (i + numVertices - 1) % numVertices;
185 unsigned int next = (i + 1) % numVertices;
194 double angle01 =
std::acos(-(edge0[0] * edge1[0] + edge0[1] * edge1[1]) / length0 / length1);
195 double angle12 =
std::acos(-(edge1[0] * edge2[0] + edge1[1] * edge2[1]) / length1 / length2);
196 double angle20 = M_PI - angle01 - angle12;
202 unsigned int numEars = ears.size();
205 unsigned int earWithMaxMinAngle = 0;
207 for (
unsigned int i = 1; i < numEars; ++ i) {
210 if (angle > maxMinAngle) {
212 earWithMaxMinAngle = i;
216 return ears[earWithMaxMinAngle];
223 while (numVertices > 3) {
226 unsigned int next = (bestEar + 1) % numVertices;
227 unsigned int previous = (bestEar + numVertices - 1) % numVertices;
double dotProduct(const Vector_t &a, const Vector_t &b)
double getAngleBetweenEdges(const Vector_t &a, const Vector_t &b)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
T::PETE_Expr_t::PETE_Return_t sum(const PETE_Expr< T > &expr)
PETE_TUTree< FnArcCos, typename T::PETE_Expr_t > acos(const PETE_Expr< T > &l)
constexpr double e
The value of.
double euclidean_norm2D(Vector_t v)
bool isPointOnLine(unsigned int i, unsigned int j, const Vector_t &pt) const
double dotProduct(unsigned int i, unsigned int j, const Vector_t &pt) const
bool isPointRightOfLine(unsigned int i, unsigned int j, const Vector_t &pt) const
std::vector< mslang::Triangle > getTriangles() const
bool isPointInsideCone(unsigned int i, unsigned int j, unsigned int jPlusOne, unsigned int jMinusOne) const
bool isConvex(unsigned int i) const
unsigned int selectBestEar(std::vector< unsigned int > &ears) const
bool lineSegmentTouchesOrCrossesLine(unsigned int i, unsigned int j, unsigned int k, unsigned int l) const
std::vector< unsigned int > findAllEars() const
std::vector< Vector_t > vertices_m
double computeMinimumAngle(unsigned int i) const
double crossProduct(const Vector_t &a, const Vector_t &b) const
Mesher(std::vector< Vector_t > &vertices)
bool isPotentialEdgeIntersected(unsigned int i) const
std::vector< mslang::Triangle > triangles_m
bool isEar(unsigned int i) const
bool doesIntersect(const BoundingBox &bb) const
std::vector< Vector_t > nodes_m