diff --git a/src/matrixmania/compute.py b/src/matrixmania/compute.py index b2a15fa..360b79c 100644 --- a/src/matrixmania/compute.py +++ b/src/matrixmania/compute.py @@ -143,6 +143,31 @@ def rot_3D(angle: float, axis: str) -> list[list[float]]: ] raise ValueError("Axis must be one of 'x', 'y', or 'z'.") +def project_ortho(point: tuple[float, float, float], scale: float = 1.0) -> tuple[float, float]: + """Orthogonal projection of a 3‑D point onto the xy‑plane. + + Parameters + ---------- + point : tuple[float, float, float] + Cartesian coordinates (x, y, z). + scale : float, optional + Scaling factor applied to x and y after projection. Defaults to 1. + + Returns + ------- + tuple[float, float] + Projected 2‑D coordinates (x_scaled, y_scaled). + + Examples + -------- + >>> project_ortho((1, 2, 3)) + (1, 2) + """ + if len(point) != 3: + raise ValueError("Point must be a 3‑tuple.") + return (point[0] * scale, point[1] * scale) + + if __name__ == "__main__": diff --git a/test/test_matrixmania/test_projection.py b/test/test_matrixmania/test_projection.py new file mode 100644 index 0000000..1f9f534 --- /dev/null +++ b/test/test_matrixmania/test_projection.py @@ -0,0 +1,15 @@ +import pytest + +from matrixmania.compute import project_ortho + + +def test_project_ortho_default(): + """Projektionsfunktion ohne Skalierung""" + point = (1.0, 2.0, 3.0) + assert project_ortho(point) == (1.0, 2.0) + + +def test_project_ortho_scaled(): + """Projektionsfunktion mit Skalierung""" + point = (1.0, 2.0, 3.0) + assert project_ortho(point, scale=100) == (100.0, 200.0)