initialer commit
This commit is contained in:
1 parent
74776ef485
commit
a3095c2df9
18 files changed
+1073
No files matched your search
@@ -0,0 +1,60 @@
|
||||
"""Tests für project_ortho und project_perspective."""
|
||||
|
||||
import pytest
|
||||
|
||||
from matrixmania import project_ortho, project_perspective
|
||||
|
||||
|
||||
def test_project_ortho_without_scale():
|
||||
# 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_100():
|
||||
# Arrange
|
||||
point = (1.0, 2.0, 3.0)
|
||||
# Act
|
||||
result = project_ortho(point, scale=100)
|
||||
# Assert
|
||||
assert result == pytest.approx((100.0, 200.0))
|
||||
|
||||
|
||||
def test_project_perspective_without_scale():
|
||||
# Arrange
|
||||
point = (1.0, 2.0, 3.0)
|
||||
# Act
|
||||
result = project_perspective(point, focal_length=1, scale=1)
|
||||
# Assert
|
||||
assert result == pytest.approx((1 / 7, 2 / 7))
|
||||
|
||||
|
||||
def test_project_perspective_with_scale_100_and_focal_length_2():
|
||||
# Arrange
|
||||
point = (1.0, 2.0, 3.0)
|
||||
# Act
|
||||
result = project_perspective(point, focal_length=2, scale=100)
|
||||
# Assert
|
||||
assert result == pytest.approx((200 / 7, 400 / 7))
|
||||
|
||||
|
||||
def test_project_perspective_far_point_appears_smaller():
|
||||
# Arrange
|
||||
near = (1.0, 1.0, 0.0)
|
||||
far = (1.0, 1.0, 10.0)
|
||||
# Act
|
||||
near_x, _ = project_perspective(near)
|
||||
far_x, _ = project_perspective(far)
|
||||
# Assert
|
||||
assert far_x < near_x
|
||||
|
||||
|
||||
def test_project_perspective_point_behind_camera_raises():
|
||||
# Arrange
|
||||
point = (1.0, 1.0, -4.0)
|
||||
# Act & Assert
|
||||
with pytest.raises(ValueError):
|
||||
project_perspective(point)
|
||||
Reference in new issue
Block a user