From 5b72de9e0577c21e92bf6bb64879849353bd150d Mon Sep 17 00:00:00 2001 From: cmiku Date: Tue, 20 Oct 2026 16:59:59 +0200 Subject: [PATCH] =?UTF-8?q?Orthogonale=20Projektion=20mit=20zwei=20Tests?= =?UTF-8?q?=20erg=C3=A4nzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/matrixmania/__init__.py | 4 +++- test/test_matrixmania/test_projection.py | 30 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 test/test_matrixmania/test_projection.py diff --git a/src/matrixmania/__init__.py b/src/matrixmania/__init__.py index c812c86..c6b2355 100644 --- a/src/matrixmania/__init__.py +++ b/src/matrixmania/__init__.py @@ -1 +1,3 @@ -from .compute import matmul, transpose, rot_2D, rot_3D \ No newline at end of file +from .compute import matmul, transpose, rot_2D, rot_3D +# Damit project_ortho direkt aus matrixmania importiert werden kann. +from .compute import project_ortho \ No newline at end of file diff --git a/test/test_matrixmania/test_projection.py b/test/test_matrixmania/test_projection.py new file mode 100644 index 0000000..65731c1 --- /dev/null +++ b/test/test_matrixmania/test_projection.py @@ -0,0 +1,30 @@ +# Wir importieren die Funktion, die wir testen möchten. +from matrixmania import project_ortho + + +def test_project_ortho_without_scaling(): + """Prüft die Projektion mit dem Standardwert scale = 1.""" + + # Vorbereitung: einen 3D-Punkt festlegen. + point = (1.0, 2.0, 3.0) + + # Aufruf ohne scale: Die Funktion verwendet automatisch 1. + result = project_ortho(point) + + # Erwartung: x und y bleiben gleich, z fällt weg. + assert result == (1.0, 2.0) + + +def test_project_ortho_with_scaling(): + """Prüft die Projektion mit dem Skalierungsfaktor 100.""" + + # Vorbereitung: denselben 3D-Punkt verwenden. + point = (1.0, 2.0, 3.0) + + # Aufruf mit scale = 100. + result = project_ortho(point, scale=100) + + # Erwartung: x und y werden mit 100 multipliziert. + # 1.0 * 100 = 100.0 + # 2.0 * 100 = 200.0 + assert result == (100.0, 200.0) \ No newline at end of file