7 commit hausaufgabe
This commit is contained in:
1 parent
83c81f8566
commit
6e76e97a4b
3 files changed
+43
-2
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from matrixmania.compute import project_ortho
|
||||
from matrixmania.compute import project_ortho, project_perspective
|
||||
|
||||
|
||||
def test_project_ortho_default():
|
||||
@@ -9,7 +9,35 @@ def test_project_ortho_default():
|
||||
assert project_ortho(point) == (1.0, 2.0)
|
||||
|
||||
|
||||
def test_project_ortho_scaled():
|
||||
def test_project_perspective_default():
|
||||
"""Test project_perspective with default scale and focal_length=1"""
|
||||
# Arrange
|
||||
point = (1.0, 2.0, 3.0)
|
||||
# Act
|
||||
result = project_perspective(point)
|
||||
# depth = z + camera_distance = 3 + 4 = 7
|
||||
# Expected x = 1 * 1 / 7 * 1 = 1/7
|
||||
# Expected y = 2 * 1 / 7 * 1 = 2/7
|
||||
expected = (1/7, 2/7)
|
||||
# Assert
|
||||
assert result == pytest.approx(expected)
|
||||
|
||||
|
||||
def test_project_perspective_scaled():
|
||||
"""Test project_perspective with scale=100 and focal_length=2"""
|
||||
# Arrange
|
||||
point = (1.0, 2.0, 3.0)
|
||||
scale = 100
|
||||
focal_length = 2
|
||||
# Act
|
||||
result = project_perspective(point, focal_length=focal_length, scale=scale)
|
||||
# depth = 3 + 4 = 7
|
||||
# Expected x = 1 * 2 / 7 * 100 = 200/7
|
||||
# Expected y = 2 * 2 / 7 * 100 = 400/7
|
||||
expected = (200/7, 400/7)
|
||||
# Assert
|
||||
assert result == pytest.approx(expected)
|
||||
|
||||
"""Projektionsfunktion mit Skalierung"""
|
||||
point = (1.0, 2.0, 3.0)
|
||||
assert project_ortho(point, scale=100) == (100.0, 200.0)
|
||||
Reference in new issue
Block a user