From 61c664dfe5b31ef618f555b23ae723766e015898 Mon Sep 17 00:00:00 2001 From: David Friedli Date: Thu, 7 Sep 2023 17:58:21 +0200 Subject: [PATCH] Constraints: Add angle vector zero length check for distance constraint Closes #413 --- model/distance.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/model/distance.py b/model/distance.py index 8010d173..e4dcd4c1 100644 --- a/model/distance.py +++ b/model/distance.py @@ -223,6 +223,7 @@ def matrix_basis(self): x_axis = Vector((1, 0)) alignment = self.align align = self.is_align() + angle = 0 e1, e2 = self.entity1, self.entity2 # e1 e2 @@ -273,7 +274,10 @@ def matrix_basis(self): if alignment == "HORIZONTAL" else Vector((0.0, 1.0)) ) - angle = v_rotation.angle_signed(x_axis) + + if v_rotation.length != 0: + angle = v_rotation.angle_signed(x_axis) + mat_rot = Matrix.Rotation(angle, 2, "Z") v_translation = (p2 + p1) / 2 @@ -291,8 +295,7 @@ def matrix_basis(self): ) if v_rotation.length != 0: angle = v_rotation.angle_signed(x_axis) - else: - angle = 0 + mat_rot = Matrix.Rotation(angle, 2, "Z") v_translation = (p2 + p1) / 2 else: