Add rotation and projection tests

This commit is contained in:
naifla103879 committed 2026-10-22 16:54:49 +02:00
1 parent f1861b4a39
commit 9aa475906e
9 files changed
+356 -148

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
from matrixmania.compute import project_ortho
def test_project_ortho_default():
# Arrange
point = (1.0, 2.0, 3.0)
expected = (1.0, 2.0)
# Act
result = project_ortho(point)
# Assert
assert result == expected
def test_project_ortho_scale_100():
# Arrange
point = (1.0, 2.0, 3.0)
expected = (100.0, 200.0)
# Act
result = project_ortho(point, scale=100)
# Assert
assert result == expected
+36
View File
@@ -0,0 +1,36 @@
import math
import pytest
from matrixmania.compute import rot_2D, rot_3D
def test_rot_2D():
# Arrange
angle = math.pi / 2
expected = [[0.0, -1.0], [1.0, 0.0]]
# Act
result = rot_2D(angle)
# Assert
for row, expected_row in zip(result, expected):
assert row == pytest.approx(expected_row)
def test_rot_3D():
# Arrange
angle = math.pi / 2
expected = [
[0.0, -1.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 0.0, 1.0],
]
# Act
result = rot_3D(angle, "z")
# Assert
for row, expected_row in zip(result, expected):
assert row == pytest.approx(expected_row)