49 double dist = iP1.
at(1) * ( iP2.
at(2) - iP3.
at(2) ) + iP2.
at(1) * ( iP3.
at(2) - iP1.
at(2) ) +
50 iP3.
at(1) * ( iP1.
at(2) - iP2.
at(2) );
52 if ( dist < mTol && dist > -
mTol ) {
61 for (
auto &tri: triangles ) {
72 double distance = circumCenter.
distance(iP);
84 if ( iVertices.size() == 4 ) {
90 const double relTol2 = 1.0e-6;
92 std :: vector< double >dist_square = {
93 iVertices [ 0 ].distance_square(iVertices [ 1 ]),
94 iVertices [ 0 ].distance_square(iVertices [ 2 ]),
95 iVertices [ 0 ].distance_square(iVertices [ 3 ])
98 std :: sort( dist_square.begin(), dist_square.end() );
101 if ( fabs(dist_square [ 2 ] - dist_square [ 1 ] - dist_square [ 0 ]) < relTol2 * dist_square [ 2 ] ) {
104 double maxDist_square = iVertices [ 0 ].distance_square(iVertices [ 1 ]);
107 if ( iVertices [ 0 ].distance_square(iVertices [ 2 ]) > maxDist_square ) {
108 maxDist_square = iVertices [ 0 ].distance_square(iVertices [ 2 ]);
112 if ( iVertices [ 0 ].distance_square(iVertices [ 3 ]) > maxDist_square ) {
113 maxDist_square = iVertices [ 0 ].distance_square(iVertices [ 3 ]);
118 int remainingInd1 = -1, remainingInd2 = -1;
120 switch ( maxDistInd ) {
141 Triangle tri1(iVertices [ 0 ], iVertices [ remainingInd1 ], iVertices [ maxDistInd ]);
146 oTriangles.push_back(tri1);
149 Triangle tri2(iVertices [ 0 ], iVertices [ remainingInd2 ], iVertices [ maxDistInd ]);
154 oTriangles.push_back(tri2);
161 int n = iVertices.size();
164 std :: vector< FloatArray >vertices(iVertices);
167 const double shift = 1.0e-12;
168 for (
int i = 1; i <= n; i++ ) {
169 vertices [ i - 1 ].at(1) += vertices [ i - 1 ].at(1) * shift * double ( rand() ) / RAND_MAX;
170 vertices [ i - 1 ].at(2) += vertices [ i - 1 ].at(2) * shift * double ( rand() ) / RAND_MAX;
173 for (
int i = 1; i <= n; i++ ) {
174 for (
int j = i + 1; j <= n; j++ ) {
175 for (
int k = j + 1; k <= n; k++ ) {
176 bool isTriangle =
true;
177 if (
colinear(vertices [ i - 1 ], vertices [ j - 1 ], vertices [ k - 1 ]) ) {
180 for (
int a = 1; a <= n; a++ ) {
181 if ( a != i && a != j && a != k ) {
183 if (
isInsideCC(vertices [ a - 1 ], vertices [ i - 1 ], vertices [ j - 1 ],
184 vertices [ k - 1 ]) ) {
194 Triangle tri(iVertices [ i - 1 ], iVertices [ j - 1 ], iVertices [ k - 1 ]);
199 oTriangles.push_back(tri);
double & at(int i)
Coefficient access function.
void sort(IntArray &arry, operation op)
Sorts the receiver using quicksort algorithm.
double distance(const FloatArray &x) const
Computes the distance between position represented by receiver and position given as parameter...
void triangulate(const std::vector< FloatArray > &iVertices, std::vector< Triangle > &oTriangles) const
void changeToAnticlockwise()
void printTriangles(std::vector< Triangle > &triangles)
bool isInsideCC(const FloatArray &iP, const FloatArray &iP1, const FloatArray &iP2, const FloatArray &iP3) const
Class representing vector of real numbers.
bool isOrientedAnticlockwise()
double getRadiusOfCircumCircle()
bool colinear(const FloatArray &iP1, const FloatArray &iP2, const FloatArray &iP3) const
the oofem namespace is to define a context or scope in which all oofem names are defined.
void computeCenterOfCircumCircle(FloatArray &answer) const