Mon, 22 Jan 2018 01:01:10 +0200
Condensed transform_to_xy
from math import acos, degrees, radians, pi as π from testsuite import warning, error from geometry import * def sign_consistency(container): # Returns whether all elements in container have the same sign return min(container) * max(container) >= 0 def concave_test(model): for quadrilateral in model.quadrilaterals: geometry = transform_to_xy(quadrilateral.geometry) z_scores = [ cross_product(v2 - v1, v3 - v1).z for v1, v2, v3 in pairs(geometry.vertices, count = 3) ] if not sign_consistency(z_scores): yield error(quadrilateral, 'Concave quadrilateral') def bowtie_quadrilateral_test(model): ... def skew_test(model): for quadrilateral in model.quadrilaterals: for triangles in split_quadrilateral(quadrilateral.geometry): plane_1 = triangle_plane_normal(triangles[0]) plane_2 = triangle_plane_normal(triangles[1]) angle = vector_angle(plane_1, plane_2, normalized = True) if angle > radians(0.1): yield error(quadrilateral, 'Skew quadrilateral (plane angle {}°)', '%.3f' % degrees(angle)) break manifest = { 'tests': {skew_test, concave_test}, }