tests/concave.py

changeset 12
eb74680a5e43
child 13
12d4ddc4bfd8
equal deleted inserted replaced
11:b42788f5d0a9 12:eb74680a5e43
1 from math import degrees, pi as π
2 from testsuite import warning
3 from geometry import *
4
5 def sign_consistency(container):
6 # Returns whether all elements in container have the same sign
7 return min(container) * max(container) >= 0
8
9 def transform_to_xy(geometry):
10 a, b, c = geometry.vertices[:3]
11
12
13 def concave_test(model):
14 for quadrilateral in model:
15 print([cross_product(v2 - v1, v3 - v1) for v1, v2, v3 in pairs(quadrilateral.geometry.vertices, count = 3)])
16 z_scores = [
17 cross_product(v2 - v1, v3 - v1).z
18 for v1, v2, v3 in pairs(quadrilateral.geometry.vertices, count = 3)
19 ]
20 print(z_scores)
21 if not sign_consistency(z_scores):
22 yield warning(quadrilateral, 'Concave quadrilateral')

mercurial