3 neue Tests hinzugefügt
This commit is contained in:
1 parent
db88d3ef07
commit
42db9a69c1
1 file changed
+43
-2
@@ -1,4 +1,7 @@
|
|||||||
from matrixmania import project_ortho
|
import pytest
|
||||||
|
|
||||||
|
from matrixmania import project_ortho, project_perspective
|
||||||
|
|
||||||
|
|
||||||
def test_project_ortho_without_scale() -> None:
|
def test_project_ortho_without_scale() -> None:
|
||||||
"""Orthogonal projection ignores z when scale is omitted."""
|
"""Orthogonal projection ignores z when scale is omitted."""
|
||||||
@@ -11,6 +14,7 @@ def test_project_ortho_without_scale() -> None:
|
|||||||
# Assert
|
# Assert
|
||||||
assert result == (1.0, 2.0)
|
assert result == (1.0, 2.0)
|
||||||
|
|
||||||
|
|
||||||
def test_project_ortho_with_scale() -> None:
|
def test_project_ortho_with_scale() -> None:
|
||||||
"""Orthogonal projection scales x and y and ignores z."""
|
"""Orthogonal projection scales x and y and ignores z."""
|
||||||
# Arrange
|
# Arrange
|
||||||
@@ -18,7 +22,44 @@ def test_project_ortho_with_scale() -> None:
|
|||||||
scale = 100
|
scale = 100
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
result = (project_ortho(point, scale=scale))
|
result = project_ortho(point, scale=scale)
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert result == (100.0, 200.0)
|
assert result == (100.0, 200.0)
|
||||||
|
|
||||||
|
|
||||||
|
def test_project_perspective_with_defaults() -> None:
|
||||||
|
"""Perspective projection uses the default focal length and distance."""
|
||||||
|
# Arrange
|
||||||
|
point = (1.0, 2.0, 3.0)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
result = project_perspective(point)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert result == pytest.approx((1 / 7, 2 / 7))
|
||||||
|
|
||||||
|
|
||||||
|
def test_project_perspective_with_scale_and_focal_length() -> None:
|
||||||
|
"""Perspective projection applies scale and focal length."""
|
||||||
|
# Arrange
|
||||||
|
point = (1.0, 2.0, 3.0)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
result = project_perspective(point, scale=100, focal_length=2)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert result == pytest.approx((200 / 7, 400 / 7))
|
||||||
|
|
||||||
|
|
||||||
|
def test_project_perspective_with_custom_camera_distance() -> None:
|
||||||
|
"""Perspective projection uses the supplied camera distance."""
|
||||||
|
# Arrange
|
||||||
|
point = (2.0, 4.0, 2.0)
|
||||||
|
camera_distance = 6.0
|
||||||
|
|
||||||
|
# Act
|
||||||
|
result = project_perspective(point, camera_distance=camera_distance)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
assert result == pytest.approx((0.25, 0.5))
|
||||||
Reference in new issue
Block a user