.git neue Ebene zugeordnet

This commit is contained in:
Rebecca committed 2026-10-22 17:04:41 +02:00
1 parent 518ef5a14a
commit db88d3ef07
6 files changed
+290

No files matched your search

View File
Whitespace-only changes.
+24
View File
@@ -0,0 +1,24 @@
from matrixmania import project_ortho
def test_project_ortho_without_scale() -> None:
"""Orthogonal projection ignores z when scale is omitted."""
# Arrange
point = (1.0, 2.0, 3.0)
# Act
result = project_ortho(point)
# Assert
assert result == (1.0, 2.0)
def test_project_ortho_with_scale() -> None:
"""Orthogonal projection scales x and y and ignores z."""
# Arrange
point = (1.0, 2.0, 3.0)
scale = 100
# Act
result = (project_ortho(point, scale=scale))
# Assert
assert result == (100.0, 200.0)
+102
View File
@@ -0,0 +1,102 @@
import math
import pytest
from matrixmania import rot_2D, rot_3D
def test_rot_2d_quarter_turn() -> None:
"""A quarter turn rotates a 2D point counterclockwise."""
# Arrange
angle = math.pi / 2
# Act
result = rot_2D(angle)
# Assert
assert result[0] == pytest.approx([0.0, -1.0])
assert result[1] == pytest.approx([1.0, 0.0])
def test_rot_3d_around_x_axis() -> None:
"""A quarter turn returns the expected matrix around x."""
# Arrange
angle = math.pi / 2
expected = [[1.0, 0.0, 0.0], [0.0, 0.0, -1.0], [0.0, 1.0, 0.0]]
# Act
result = rot_3D(angle, "x")
# Assert
for actual_row, expected_row in zip(result, expected):
assert actual_row == pytest.approx(expected_row)
def test_rot_3d_around_y_axis() -> None:
"""A quarter turn returns the expected matrix around y."""
# Arrange
angle = math.pi / 2
expected = [[0.0, 0.0, 1.0], [0.0, 1.0, 0.0], [-1.0, 0.0, 0.0]]
# Act
result = rot_3D(angle, "y")
# Assert
for actual_row, expected_row in zip(result, expected):
assert actual_row == pytest.approx(expected_row)
def test_rot_3d_around_z_axis() -> None:
"""A quarter turn returns the expected matrix around z."""
# 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 actual_row, expected_row in zip(result, expected):
assert actual_row == pytest.approx(expected_row)
def test_rot_3d_rejects_empty_axis() -> None:
"""An empty axis is invalid."""
# Arrange
angle = math.pi / 2
axis = ""
# Act
with pytest.raises(ValueError) as error:
rot_3D(angle, axis)
# Assert
assert str(error.value) == "axis must be 'x', 'y', or 'z'"
def test_rot_3d_rejects_unknown_axis() -> None:
"""An unknown axis is invalid."""
# Arrange
angle = math.pi / 2
axis = "a"
# Act
with pytest.raises(ValueError) as error:
rot_3D(angle, axis)
# Assert
assert str(error.value) == "axis must be 'x', 'y', or 'z'"
def test_rot_3d_rejects_uppercase_axis() -> None:
"""Axis values must be lowercase."""
# Arrange
angle = math.pi / 2
axis = "X"
# Act
with pytest.raises(ValueError) as error:
rot_3D(angle, axis)
# Assert
assert str(error.value) == "axis must be 'x', 'y', or 'z'"