52 lines
1.0 KiB
Python
52 lines
1.0 KiB
Python
import pytest
|
|
|
|
from matrixmania import project_ortho, project_perspective
|
|
|
|
|
|
def test_project_ortho_without_scale():
|
|
# 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_with_scale_100():
|
|
# Arrange
|
|
point = (1.0, 2.0, 3.0)
|
|
scale = 100
|
|
expected = (100.0, 200.0)
|
|
|
|
# Act
|
|
result = project_ortho(point, scale=scale)
|
|
|
|
# Assert
|
|
assert result == expected
|
|
|
|
|
|
def test_project_perspective_without_scale():
|
|
# Arrange
|
|
point = (1.0, 2.0, 3.0)
|
|
expected = (1 / 7, 2 / 7)
|
|
|
|
# Act
|
|
result = project_perspective(point, focal_length=1, scale=1)
|
|
|
|
# Assert
|
|
assert result == pytest.approx(expected)
|
|
|
|
|
|
def test_project_perspective_with_scale_100_and_focal_length_2():
|
|
# Arrange
|
|
point = (1.0, 2.0, 3.0)
|
|
expected = (200 / 7, 400 / 7)
|
|
|
|
# Act
|
|
result = project_perspective(point, focal_length=2, scale=100)
|
|
|
|
# Assert
|
|
assert result == pytest.approx(expected) |