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

View File
Whitespace-only changes.
+16
View File
@@ -0,0 +1,16 @@
import pytest
from matrixmania.compute import project_ortho
def test_project_ortho_default_scale():
# Test ohne Angabe von scale (Standardwert = 1)
point = (1.0, 2.0, 3.0)
result = project_ortho(point)
assert result == (1.0, 2.0)
def test_project_ortho_with_scale():
# Test mit scale = 100
point = (1.0, 2.0, 3.0)
result = project_ortho(point, scale=100)
assert result == (100.0, 200.0)
+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")