# HG changeset patch # User Teemu Piippo # Date 1561360596 -10800 # Node ID 6ae063fd27dc80460fe630cc5d79fa734c2d0247 # Parent d2b277cb948ed414d8252197d044357d2b77ecb8 fixed the collinear test for polygons with identical vertices diff -r d2b277cb948e -r 6ae063fd27dc geometry.py --- a/geometry.py Mon Jun 24 10:13:13 2019 +0300 +++ b/geometry.py Mon Jun 24 10:16:36 2019 +0300 @@ -197,12 +197,13 @@ yield LineSegment(v1, v2) @property def angles(self): - from math import acos + from math import acos, isclose for v1, v2, v3 in pairs(self.vertices, count = 3): vec1 = (position_vector(v3) - position_vector(v2)).normalized() vec2 = (position_vector(v1) - position_vector(v2)).normalized() - cosine = dot_product(vec1, vec2) / vec1.length() / vec2.length() - yield acos(cosine) + if not isclose(vec1.length(), 0) and not isclose(vec2.length(), 0): + cosine = dot_product(vec1, vec2) / vec1.length() / vec2.length() + yield acos(cosine) @property def smallest_angle(self): return min( diff -r d2b277cb948e -r 6ae063fd27dc tests/quadrilaterals.py --- a/tests/quadrilaterals.py Mon Jun 24 10:13:13 2019 +0300 +++ b/tests/quadrilaterals.py Mon Jun 24 10:16:36 2019 +0300 @@ -84,6 +84,7 @@ for a, b, c in pairs(element.geometry.vertices, count = 3): if cross_product(b - a, c - a).length() < 1e-5: yield report_problem('collinear', bad_object = element) + break @problem_type('hairline-polygon', severity = 'warning',