make sure matrix is 3x3 for calculation
This commit is contained in:
themancalledjakob 2024-08-07 13:11:35 +02:00
parent bae99ee4c6
commit 0750cc56e3

View file

@ -130,11 +130,11 @@ def align_rotations_auto_pivot(mask, input_rotations, vectors, factors, local_ma
if rotation_axis.length < 1e-6: if rotation_axis.length < 1e-6:
# Vectors are linearly dependent, fallback to another axis # Vectors are linearly dependent, fallback to another axis
rotation_axis = (old_axis + mathutils.Matrix().col[2]).normalized() rotation_axis = (old_axis + mathutils.Matrix().to_3x3().col[2]).normalized()
if rotation_axis.length < 1e-6: if rotation_axis.length < 1e-6:
# This is now guaranteed to not be zero # This is now guaranteed to not be zero
rotation_axis = (-(old_axis) + mathutils.Matrix().col[1]).normalized() rotation_axis = (-(old_axis) + mathutils.Matrix().to_3x3().col[1]).normalized()
# full_angle = radians(sqrt((4 * pow(input_rotation.to_quaternion().dot(mathutils.Quaternion(vectors[i].normalized())), 2) - 3))) # full_angle = radians(sqrt((4 * pow(input_rotation.to_quaternion().dot(mathutils.Quaternion(vectors[i].normalized())), 2) - 3)))
# dot = old_axis.dot(new_axis) # dot = old_axis.dot(new_axis)