17 for (
unsigned int i = 0; i < size; ++ i) {
18 unsigned int iPlusOne = (i + 1) % size;
22 sum += edge[0] * edge[1];
24 if (
sum <= 0.0)
return;
34 unsigned int iPlusOne = (i + 1) % numVertices;
35 unsigned int iMinusOne = (i + numVertices - 1) % numVertices;
40 double vectorProduct = edge0[0] * edge1[1] - edge0[1] * edge1[0];
42 return (vectorProduct < 0.0);
47 return a[0] * b[1] -
a[1] * b[0];
58 return std::abs(r) < 1e-10;
73 unsigned int l)
const {
82 if (numVertices < 5)
return false;
85 unsigned int iPlusOne = (i + 1) % numVertices;
86 unsigned int iMinusOne = (i + numVertices - 1) % numVertices;
93 for (
unsigned int j = iPlusOne + 1; j < iPlusOne + numVertices - 3; ++ j) {
94 unsigned int k = (j % numVertices);
95 unsigned int kPlusOne = ((k + 1) % numVertices);
106 iPlusOne, iMinusOne))
118 double angle = std::acos((
a[0] * b[0] +
a[1] * b[1]) / lengthA / lengthB);
119 if (
a[0] * b[1] -
a[1] * b[0] < 0.0)
131 return edge0[0] * edge1[0] + edge0[1] * edge1[1];
136 return a[0] * b[0] +
a[1] * b[1];
141 unsigned int jPlusOne,
142 unsigned int jMinusOne)
const {
154 unsigned int iMinusTwo = (i + size - 2) % size;
155 unsigned int iMinusOne = (i + size - 1) % size;
156 unsigned int iPlusOne = (i + 1) % size;
157 unsigned int iPlusTwo = (i + 2) % size;
172 std::vector<unsigned int> ears;
174 for (
unsigned int i = 0; i < size; ++ i) {
185 unsigned int previous = (i + numVertices - 1) % numVertices;
186 unsigned int next = (i + 1) % numVertices;
195 double angle01 = std::acos(-(edge0[0] * edge1[0] + edge0[1] * edge1[1]) / length0 / length1);
196 double angle12 = std::acos(-(edge1[0] * edge2[0] + edge1[1] * edge2[1]) / length1 / length2);
199 return std::min(std::min(angle01, angle12), angle20);
203 unsigned int numEars = ears.size();
206 unsigned int earWithMaxMinAngle = 0;
208 for (
unsigned int i = 1; i < numEars; ++ i) {
211 if (angle > maxMinAngle) {
213 earWithMaxMinAngle = i;
217 return ears[earWithMaxMinAngle];
224 while (numVertices > 3) {
227 unsigned int next = (bestEar + 1) % numVertices;
228 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 sum(const PETE_Expr< T > &expr)
constexpr double pi
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 BoundingBox2D &bb) const
std::vector< Vector_t > nodes_m