import pytest from compute import project_ortho, project_perspective def test_project_ortho_without_scaling() -> None: """Test orthogonal projection without scaling.""" # 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_scaling() -> None: """Test orthogonal projection with a scale factor of 100.""" # Arrange point = (1.0, 2.0, 3.0) scale = 100 expected = (100.0, 200.0) # Act result = project_ortho(point, scale) # Assert assert result == expected def test_project_perspective_without_scaling() -> None: """Test perspective projection with default parameters.""" # Arrange point = (1.0, 2.0, 3.0) expected = (1 / 7, 2 / 7) # Act result = project_perspective(point) # Assert assert result == pytest.approx(expected) def test_project_perspective_with_scaling() -> None: """Test perspective projection with scaling and focal length.""" # Arrange point = (1.0, 2.0, 3.0) focal_length = 2.0 scale = 100.0 expected = (200 / 7, 400 / 7) # Act result = project_perspective( point, focal_length=focal_length, scale=scale, ) # Assert assert result == pytest.approx(expected) def test_project_perspective_zero_depth() -> None: """Test that zero projection depth raises an error.""" # Arrange point = (1.0, 2.0, -4.0) # Act & Assert with pytest.raises(ValueError): project_perspective(point) # python -m pytest test_matrixmania/test_projection.py -v