5 def sign_consistency(container): |
5 def sign_consistency(container): |
6 # Returns whether all elements in container have the same sign |
6 # Returns whether all elements in container have the same sign |
7 return min(container) * max(container) >= 0 |
7 return min(container) * max(container) >= 0 |
8 |
8 |
9 def concave_test(model): |
9 def concave_test(model): |
|
10 ''' Checks that all quadrilaterals are convex. ''' |
10 for quadrilateral in model.quadrilaterals: |
11 for quadrilateral in model.quadrilaterals: |
11 geometry = transform_to_xy(quadrilateral.geometry) |
12 geometry = transform_to_xy(quadrilateral.geometry) |
12 z_scores = [ |
13 z_scores = [ |
13 cross_product(v2 - v1, v3 - v1).z |
14 cross_product(v2 - v1, v3 - v1).z |
14 for v1, v2, v3 in pairs(geometry.vertices, count = 3) |
15 for v1, v2, v3 in pairs(geometry.vertices, count = 3) |
15 ] |
16 ] |
16 if not sign_consistency(z_scores): |
17 if not sign_consistency(z_scores): |
17 yield error(quadrilateral, 'concave-error') |
18 yield error(quadrilateral, 'concave-error') |
18 |
19 |
19 def skew_test(model): |
20 def skew_test(model): |
20 ''' Test for non-coplanar quadrilaterals. ''' |
21 ''' Checks that all quadrilaterals are coplanar. ''' |
21 for quadrilateral in model.quadrilaterals: |
22 for quadrilateral in model.quadrilaterals: |
22 for triangles in split_quadrilateral(quadrilateral.geometry): |
23 for triangles in split_quadrilateral(quadrilateral.geometry): |
23 plane_1 = triangle_plane_normal(triangles[0]) |
24 plane_1 = triangle_plane_normal(triangles[0]) |
24 plane_2 = triangle_plane_normal(triangles[1]) |
25 plane_2 = triangle_plane_normal(triangles[1]) |
25 skew_angle = vector_angle(plane_1, plane_2, normalized = True) |
26 skew_angle = vector_angle(plane_1, plane_2, normalized = True) |