From aa7f72820bf597d640bbcd311c1261d9faf6afa4 Mon Sep 17 00:00:00 2001 From: dimartinoma102424 Date: Mon, 3 Nov 2025 15:08:56 +0100 Subject: [PATCH 1/4] Test Dokument erstellt --- docs/tests.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/tests.txt diff --git a/docs/tests.txt b/docs/tests.txt new file mode 100644 index 0000000..e69de29 From a8b2545b6c609c9403dff7355f58398274a0e82b Mon Sep 17 00:00:00 2001 From: dimartinoma102424 Date: Mon, 3 Nov 2025 15:29:22 +0100 Subject: [PATCH 2/4] marco test files --- docs/tests.cpp | 3 +++ docs/tests.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 docs/tests.cpp diff --git a/docs/tests.cpp b/docs/tests.cpp new file mode 100644 index 0000000..7c928ae --- /dev/null +++ b/docs/tests.cpp @@ -0,0 +1,3 @@ +// +// Created by marco on 03.11.2025. +// diff --git a/docs/tests.txt b/docs/tests.txt index e69de29..2b301a5 100644 --- a/docs/tests.txt +++ b/docs/tests.txt @@ -0,0 +1,42 @@ +======================================================== +Projekt: gamematrix (C++ Library) +Rolle: Tester +Datei: tests.txt +Datum: ____________________ +Team: ____________________ +======================================================== + +# ---------------------------- +# 1. Testplan Übersicht +# ---------------------------- +Ziel: Überprüfung der Funktionen matmul(), translate(), rot3D(). + +| Funktion | Testfall | Eingabe | Erwartetes Ergebnis | Bemerkung | +|---------------|---------------------------|------------------------------|-----------------------------------|----------------------------| +| matmul | Identity * Identity | 4x4 Identity Matrizen | Identity | Basisfall | +| matmul | Beispielmatrizen | A=[[...]], B=[[...]] | C=[[...]] | Prüfen mit Handrechnung | +| translate | Verschiebung | Vec3 {1,2,3} | Matrix mit Translation 1,2,3 | Prüfen letzte Spalte | +| rot3D | Rotation Z 90° | angle_deg=90, axis='z' | (1,0,0) -> (0,1,0) | Prüfen Anwendung auf Vektor| +| rot3D | Rotation X 180° | angle_deg=180, axis='x' | (0,1,0) -> (0,-1,0) | Prüfen Anwendung auf Vektor| +| rot3D | Rotation Y 270° | angle_deg=270, axis='y' | (1,0,0) -> (0,0,-1) | Prüfen Anwendung auf Vektor| + + +# ---------------------------- +# 2. Testdaten / Matrizen +# ---------------------------- +- Matrizen für matmul: Identity, Beispiel A/B Matrizen +- Vektoren für translate: Vec3 {x, y, z} +- Vektoren für rot3D: Vec3 {1,0,0}, Vec3 {0,1,0} + +# ---------------------------- +# 3. Abnahmekriterien +# ---------------------------- +- Alle Unit-Tests erfolgreich +- Keine Exceptions außer gewollt (z. B. ungültige Achse) +- Testbericht in tests.txt dokumentiert + +======================================================== +Hinweis: +- Diese Datei wird vom Tester gepflegt. +- Tester dokumentiert Input, Output, erwartetes Ergebnis und Erfolg/Fehler. +======================================================== \ No newline at end of file From 8023f4e866aea1ec522d4b60fd55768461684bb7 Mon Sep 17 00:00:00 2001 From: dimartinoma102424 Date: Mon, 3 Nov 2025 15:31:53 +0100 Subject: [PATCH 3/4] CMAKE list is f***ed --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a33740..0f9189f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ set(SRC_FILES ${CMAKE_CURRENT_LIST_DIR}/src/main.cpp ${CMAKE_CURRENT_LIST_DIR}/src/gamecube.cpp src/gamematrix.cpp + docs/tests.cpp ) ##Tom: prev: ${CMAKE_CURRENT_LIST_DIR}/linux -> now /include From 5b467f42ae34acd3b5f7eadf24e3b95179d0e9fa Mon Sep 17 00:00:00 2001 From: dimartinoma102424 Date: Mon, 17 Nov 2025 14:17:38 +0100 Subject: [PATCH 4/4] tests.cpp commited --- docs/tests.cpp | 136 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 1 deletion(-) diff --git a/docs/tests.cpp b/docs/tests.cpp index 7c928ae..756c871 100644 --- a/docs/tests.cpp +++ b/docs/tests.cpp @@ -1,3 +1,137 @@ // // Created by marco on 03.11.2025. -// +// Changeb by marco on 16.11.2025 + +#include +#include +#include "gamematrix.h" + +using namespace Matrix3D; + +bool nearlyEqual(double a, double b, double eps = 1e-6) { + return std::abs(a - b) < eps; +} + +void test_matmul_identity() { + Mat4 A = identity(); + Mat4 B = identity(); + Mat4 R = matmul(A, B); + + std::cout << "Test matmul: Identity * Identity -> Identity: "; + + bool ok = true; + for(int i=0;i<4;i++){ + for(int j=0;j<4;j++){ + double expected = (i==j ? 1.0 : 0.0); + if(!nearlyEqual(R[i][j], expected)) ok = false; + } + } + + std::cout << (ok ? "OK\n" : "FAIL\n"); +} + +void test_matmul_example() { + Mat4 A = {{ + {{1, 2, 3, 4}}, + {{0, 1, 2, 3}}, + {{0, 0, 1, 2}}, + {{0, 0, 0, 1}} + }}; + + Mat4 B = {{ + {{1, 0, 0, 0}}, + {{1, 1, 0, 0}}, + {{1, 1, 1, 0}}, + {{1, 1, 1, 1}} + }}; + + Mat4 R = matmul(A, B); + + std::cout << "Test matmul: Beispielmatrizen A * B: "; + + // Erwartete Matrix mit Handrechnung: + Mat4 Expected = {{ + {{1+2+3+4, 2+3+4, 3+4, 4}}, + {{0+1+2+3, 1+2+3, 2+3, 3}}, + {{0+0+1+2, 0+1+2, 1+2, 2}}, + {{1, 1, 1, 1}} + }}; + + bool ok = true; + for(int i=0;i<4;i++){ + for(int j=0;j<4;j++){ + if(!nearlyEqual(R[i][j], Expected[i][j])) ok = false; + } + } + + std::cout << (ok ? "OK\n" : "FAIL\n"); +} + +void test_translate() { + Vec3 v{1,2,3}; + Mat4 T = translate({5,-2,1}); + Vec3 out = T * v; + + std::cout << "Test translate (Vec3{1,2,3} + {5,-2,1}): "; + + if(nearlyEqual(out.x, 6) && nearlyEqual(out.y, 0) && nearlyEqual(out.z, 4)) + std::cout << "OK\n"; + else + std::cout << "FAIL (" << out.x << "," << out.y << "," << out.z << ")\n"; +} + +void test_rotZ_90() { + Vec3 v{1,0,0}; + Mat4 Rm = rot3D(90, 'z'); + Vec3 out = Rm * v; + + std::cout << "Test rot3D Z 90° (1,0,0 -> 0,1,0): "; + + if(nearlyEqual(out.x, 0) && nearlyEqual(out.y, 1)) + std::cout << "OK\n"; + else + std::cout << "FAIL (" << out.x << "," << out.y << "," << out.z << ")\n"; +} + +void test_rotX_180() { + Vec3 v{0,1,0}; + Mat4 Rm = rot3D(180, 'x'); + Vec3 out = Rm * v; + + std::cout << "Test rot3D X 180° (0,1,0 -> 0,-1,0): "; + + if(nearlyEqual(out.y, -1)) + std::cout << "OK\n"; + else + std::cout << "FAIL (" << out.x << "," << out.y << "," << out.z << ")\n"; +} + +void test_rotY_270() { + Vec3 v{1,0,0}; + Mat4 Rm = rot3D(270, 'y'); + Vec3 out = Rm * v; + + std::cout << "Test rot3D Y 270° (1,0,0 -> 0,0,-1): "; + + if(nearlyEqual(out.x, 0) && nearlyEqual(out.z, -1)) + std::cout << "OK\n"; + else + std::cout << "FAIL (" << out.x << "," << out.y << "," << out.z << ")\n"; +} + +int main() { + std::cout << "===== Matrix3D Tests =====\n"; + + test_matmul_identity(); + test_matmul_example(); + + test_translate(); + + test_rotZ_90(); + test_rotX_180(); + test_rotY_270(); + + std::cout << "==========================\n"; + return 0; +} +