# HG changeset patch # User Santeri Piippo # Date 1516575670 -7200 # Node ID 45b3aeb25003b322cb427290b0dc852995c7b46f # Parent d383f319f35bc05f1a06f036cdad060d4f69984e Condensed transform_to_xy diff -r d383f319f35b -r 45b3aeb25003 geometry.py --- a/geometry.py Mon Jan 22 12:22:01 2018 +0200 +++ b/geometry.py Mon Jan 22 01:01:10 2018 +0200 @@ -371,17 +371,15 @@ v1, v2, v3 = polygon.vertices[:3] a, b = v3 - v2, v1 - v2 normal = cross_product(a, b).normalized() - v = cross_product(normal, Vector(0, 0, 1)) - cosine = dot_product(normal, Vector(0, 0, 1)) v_matrix = Matrix3x3([ - 0, -v.z, v.y, - v.z, 0, -v.x, - -v.y, v.x, 0, + 0, 0, -normal.x, + 0, 0, -normal.y, + normal.x, normal.y, 0, ]) try: rotation_matrix = Matrix3x3() rotation_matrix += v_matrix - rotation_matrix += (v_matrix @ v_matrix) * (1 / (1 + cosine)) + rotation_matrix += (v_matrix @ v_matrix) * (1 / (1 + normal.z)) except ZeroDivisionError: rotation_matrix = Matrix3x3() full_matrix = complete_matrix(rotation_matrix, Vertex(0, 0, 0))