Skip to content

Commit

Permalink
Constraints: Add angle vector zero length check for distance constraint
Browse files Browse the repository at this point in the history
Closes #413
  • Loading branch information
hlorus committed Sep 7, 2023
1 parent 0c58f92 commit 61c664d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions model/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand Down

0 comments on commit 61c664d

Please sign in to comment.