Skip to content

Commit 06c99b7

Browse files
committed
Merge branch 'develop' of
https://github.com/jwwild/UnstructuredMeshAnalyzer into develop Conflicts: geom_utils.cxx
2 parents df6b300 + 3f42c8f commit 06c99b7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

geom_utils.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ angleBetweenVecs(const double vecA[3], const double vecB[3],
180180
}
181181

182182
static double
183-
triArea_old(const double coords[][3], const GMGW_int v0, const GMGW_int v1,
183+
triArea(const double coords[][3], const GMGW_int v0, const GMGW_int v1,
184184
const GMGW_int v2)
185185
{
186186
double e0 = distance(coords[v0], coords[v1]);
@@ -201,7 +201,12 @@ triArea_old(const double coords[][3], const GMGW_int v0, const GMGW_int v1,
201201
}
202202
assert(e0 >= e1);
203203
assert(e1 >= e2);
204-
assert(e2 >= (e0-e1)); // astonishingly numerically possible for 180° inner edge angle (jww)
204+
if (e2 - (e0 -e1) < 0) {
205+
// These three edge lengths can't be a real triangle, because e0
206+
// is larger than the sum of e1 and e2. Treat this triangle as
207+
// exactly linear, and return zero area.
208+
return 0;
209+
}
205210
// The parentheses enforce a numerically stable order of operations.
206211
double Area = 0.25
207212
* sqrt(
@@ -211,7 +216,7 @@ triArea_old(const double coords[][3], const GMGW_int v0, const GMGW_int v1,
211216
}
212217

213218
static double // replaces previous edge-length based version (jww)
214-
triArea(const double coords[][3], const GMGW_int v0, const GMGW_int v1,
219+
triArea_alternative(const double coords[][3], const GMGW_int v0, const GMGW_int v1,
215220
const GMGW_int v2)
216221
{
217222
// the following is unneeded computational overshoot - only for the assertion below

0 commit comments

Comments
 (0)