projection & 3Drot

This commit is contained in:
AnnalenaTH committed 2026-10-22 13:31:17 +02:00
1 parent 87feb62121
commit e4d36ad733
4 files changed
+106

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import math
import pytest
from matrixmania.compute import rot_3D
def test_rot_3D_x_axis():
# Test bei 0 Radian (Identitätsmatrix)
res = rot_3D(0.0, "x")
assert res == [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
# Test bei 90 Grad (PI / 2)
res_90 = rot_3D(math.pi / 2, "x")
assert pytest.approx(res_90[1][1]) == 0.0
assert pytest.approx(res_90[1][2]) == -1.0
assert pytest.approx(res_90[2][1]) == 1.0
assert pytest.approx(res_90[2][2]) == 0.0
def test_rot_3D_y_axis():
res = rot_3D(0.0, "y")
assert res == [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
def test_rot_3D_z_axis():
res = rot_3D(0.0, "z")
assert res == [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]
def test_rot_3D_invalid_axis():
# Prüft, ob bei ungültiger Achse ein ValueError geworfen wird
with pytest.raises(ValueError):
rot_3D(1.0, "w")