53 lines
1.0 KiB
Python
53 lines
1.0 KiB
Python
|
|
import pytest
|
|
|
|
from matrixmania.compute import project_ortho, project_perspective
|
|
|
|
|
|
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
|
|
|
|
|
|
def test_project_perspective_default():
|
|
# Arrange
|
|
point = (1.0, 2.0, 3.0)
|
|
expected = (1.0 / 7.0, 2.0 / 7.0)
|
|
|
|
# Act
|
|
result = project_perspective(point)
|
|
|
|
# Assert
|
|
assert result == pytest.approx(expected)
|
|
|
|
|
|
def test_project_perspective_focal_length_2_scale_100():
|
|
# Arrange
|
|
point = (1.0, 2.0, 3.0)
|
|
expected = ((1.0 * 2.0 / 7.0) * 100, (2.0 * 2.0 / 7.0) * 100)
|
|
|
|
# Act
|
|
result = project_perspective(point, focal_length=2.0, scale=100)
|
|
|
|
# Assert
|
|
assert result == pytest.approx(expected)
|