np_matrix_to_euler, np_matrix_normalized

This commit is contained in:
Andrej730
2025-01-13 13:22:04 +05:00
parent 0ac9d739f8
commit a968b61d02
2 changed files with 41 additions and 0 deletions
@@ -30,6 +30,7 @@ from ifcopenshell.util.shape_builder import (
np_angle_signed,
np_normal,
np_intersect_line_line,
np_matrix_to_euler,
)
from math import degrees, radians
from typing import Any, Union
@@ -57,6 +58,21 @@ class TestMathutilsCompatibleMethods(test.bootstrap.IFC4):
rotation_vector_args = radians(45), 4, Vector((1, 1, 1)).normalized()
assert np.allclose(Matrix.Rotation(*rotation_vector_args), np_rotation_matrix(*rotation_vector_args))
def test_np_matrix_to_euler(self):
from mathutils import Euler
# Test 3x3.
rot = Euler((0.5, 0.5, 0.5)).to_matrix()
assert np.allclose(rot.to_euler(), np_matrix_to_euler(V(rot)))
rot = rot.to_4x4()
assert np.allclose(rot.to_euler(), np_matrix_to_euler(V(rot)))
# Ensure support scaled matrices.
rot = Euler((0.5, 0.5, 0.5)).to_matrix()
rot.col[0] *= 2
assert np.allclose(rot.to_euler(), np_matrix_to_euler(V(rot)))
def test_np_angle(self):
from mathutils import Vector