diff --git a/compute.py b/compute.py index 2689316..24f7d15 100644 --- a/compute.py +++ b/compute.py @@ -200,6 +200,27 @@ def rot_3D(angle: float, axis: str) -> list[list[float]]: raise ValueError(f"Unsupported rotation axis: {axis}") +def project_ortho( + point: tuple[float, float, float], scale: float = 1 +) -> tuple[float, float]: + """Project a 3‑D point orthogonally onto the xy‑plane. + + Parameters + ---------- + point : tuple[float, float, float] + Coordinates (x, y, z) of the point. + scale : float, optional + Scaling factor applied to the projected x and y. + + Returns + ------- + tuple[float, float] + The projected (x, y) after scaling. + """ + x, y, _ = point + return (x * scale, y * scale) + + if __name__ == "__main__": # matmul tests a1 = [[1, 2], [3, 4]] diff --git a/test/test_matrixmania/test_projection.py b/test/test_matrixmania/test_projection.py index e69de29..269d9ef 100644 --- a/test/test_matrixmania/test_projection.py +++ b/test/test_matrixmania/test_projection.py @@ -0,0 +1,23 @@ +from compute import project_ortho + + +def test_ortho_1(): + # Arrange + punkt = (1.0, 2.0, 3.0) + scale = 1 + erwartet = (1.0, 2.0) + # Act + ergebnis = project_ortho(punkt, scale) + # Assert + assert ergebnis == erwartet + + +def test_ortho_100(): + # Arrange + punkt = (1.0, 2.0, 3.0) + scale = 100 + erwartet = (100.0, 200.0) + # Act + ergebnis = project_ortho(punkt, scale) + # Assert + assert ergebnis == erwartet