diff -r 02e7e1d73ebb -r 75f44d3063da tests/quadrilaterals.py --- a/tests/quadrilaterals.py Wed Jan 24 23:14:01 2018 +0200 +++ b/tests/quadrilaterals.py Wed Jan 31 14:34:23 2018 +0200 @@ -1,5 +1,5 @@ from math import radians -from testsuite import warning, error +from testsuite import warning, error, notice from geometry import * def sign_consistency(container): @@ -58,12 +58,26 @@ if cross_product(b - a, c - a).length() < 1e-5: yield error(element, 'collinearity-error') +def hairline_score(smallest_angle): + from math import log10 + return max(0, -log10(smallest_angle)) + +def hairline_test(model): + for element in model.body: + if hasattr(element, 'geometry') and len(element.geometry.vertices) >= 3: + smallest_angle = element.geometry.smallest_angle + if smallest_angle < radians(0.5): + yield notice(element, 'hairline-warning', + smallest_angle = smallest_angle, + ) + manifest = { 'tests': { 'skew': skew_test, 'concave': concave_test, 'bowtie': bowtie_test, 'collinearity': collinear_test, + 'hairline': hairline_test, }, 'messages': { 'skew-error': lambda skew_angle: @@ -77,5 +91,9 @@ 'concave-error': 'concave quadrilateral', 'self-intersecting': 'bowtie quadrilateral', 'collinearity-error': 'collinear polygon', + 'hairline-warning': lambda smallest_angle: + str.format('hairline polygon (smallest angle {})', + degree_rep(smallest_angle), + ), }, }