From 5ff1281385c43bfd938274e0aff65b06183f8754 Mon Sep 17 00:00:00 2001 From: graapka99558 Date: Mon, 3 Nov 2025 15:04:36 +0100 Subject: [PATCH 1/7] Docs Design + Gamematrix --- docs/design.txt | 74 ++++++++++++++++++++++++++++++++++++++++++++++ src/gamematrix.cpp | 3 -- 2 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 docs/design.txt diff --git a/docs/design.txt b/docs/design.txt new file mode 100644 index 0000000..9453466 --- /dev/null +++ b/docs/design.txt @@ -0,0 +1,74 @@ +======================================================== +Projekt: gamematrix (C++ Library) +Rolle: Architekt +Datei: design.txt +Datum: ____________________ +Team: ____________________ +======================================================== + +# ---------------------------- +# 1. Projektstruktur / Namespace +# ---------------------------- +Namespace: _______________________________________________ + +Ziel: Saubere Trennung der Bibliothek, Vermeidung von Namenskonflikten. + +Beispiel: +namespace Matrix3D { + // Funktionen, ggf Klasse(n) +} + +# ---------------------------- +# 2. Datenstrukturen / Klassen +# ---------------------------- +Listen Sie die Klassen oder Structs auf, die verwendet werden: + +| Name | Typ | Beschreibung | +|--------|------------------------------------------|--------------| +| Vec3 | struct Vec3 | 3D-Vektor (x, y, z) | +| Mat4 | std::array,4> | 4x4-Matrix (homogen) | +| ______ | ________ | ___________________ | +| ______ | ________ | ___________________ | + +# ---------------------------- +# 3. Operatoren / Templates +# ---------------------------- +Welche Operatoren oder Templates sollen definiert werden? + +- Templates für unterschiedliche Datentypen? ☐ Ja ☐ Nein +- Operatoren: + - Mat4 * Mat4 + - Mat4 * Vec3 + +# ---------------------------- +# 4. Funktionen / Schnittstellen +# ---------------------------- +Liste der Funktionen mit Eingabe/Ausgabe und kurzer Beschreibung: + +| Funktion | Eingabe | Ausgabe | Kurzbeschreibung | +|---------------|------------------------------------|-----------------------|----------------------------------------| +| matmul | Mat4 A, Mat4 B | Mat4 | Matrixmultiplikation 4x4 | +| translate | Vec3 pos | Mat4 | Verschiebungstransformation | +| rot3D | double angle_deg, char axis | Mat4 | Rotation um Achse x/y/z | +| identity (optional)| --- | Mat4 | Identitätsmatrix | +| _____________ | __________________________________ | ____________________ | ______________________________ | + +# ---------------------------- +# 5. Designentscheidungen / Hinweise +# ---------------------------- +- Rückgabe der Matrizen per Wert oder Referenz? ___________ +- Verwendung von std::array oder std::vector? ___________ +- Homogene Koordinaten für Translation / Rotation (4x4)? ☐ Ja ☐ Nein +- Weitere Designüberlegungen: ___________________________ + +# ---------------------------- +# 6. Deliverables / Milestones +# ---------------------------- +- design.txt fertig und im Branch architect committed +- Übergabe an Entwickler für Implementierung + +======================================================== +Hinweis: +- Dieses Dokument dient als Grundlage für die Implementierung. +- Alle Designentscheidungen sollen klar nachvollziehbar sein. +======================================================== \ No newline at end of file diff --git a/src/gamematrix.cpp b/src/gamematrix.cpp index 4dfee12..e69de29 100644 --- a/src/gamematrix.cpp +++ b/src/gamematrix.cpp @@ -1,3 +0,0 @@ -// -// Created by kmust on 03.11.2025. -// From 0c71e3d2c75029055ff38efc8dd26e6cf40a71d0 Mon Sep 17 00:00:00 2001 From: graapka99558 Date: Mon, 3 Nov 2025 15:10:58 +0100 Subject: [PATCH 2/7] Docs Design --- docs/design.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/design.txt b/docs/design.txt index 9453466..4c26016 100644 --- a/docs/design.txt +++ b/docs/design.txt @@ -2,8 +2,8 @@ Projekt: gamematrix (C++ Library) Rolle: Architekt Datei: design.txt -Datum: ____________________ -Team: ____________________ +Datum: 03-November +Team: Thomas&Co ======================================================== # ---------------------------- From 96a19a6312e54adac22ce35a7e6f5c4757444441 Mon Sep 17 00:00:00 2001 From: graapka99558 Date: Mon, 3 Nov 2025 15:21:44 +0100 Subject: [PATCH 3/7] =?UTF-8?q?Design.txt=20=C3=84nderungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/design.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/design.txt b/docs/design.txt index 4c26016..c04aa00 100644 --- a/docs/design.txt +++ b/docs/design.txt @@ -9,7 +9,7 @@ Team: Thomas&Co # ---------------------------- # 1. Projektstruktur / Namespace # ---------------------------- -Namespace: _______________________________________________ +Namespace: Matrix3D Ziel: Saubere Trennung der Bibliothek, Vermeidung von Namenskonflikten. From a561b264256ba54733e8d5674cb882e92958af45 Mon Sep 17 00:00:00 2001 From: graapka99558 Date: Mon, 3 Nov 2025 15:24:49 +0100 Subject: [PATCH 4/7] CMake angepasst --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a33740..d30ec3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ target_include_directories(${EXECUTABLE_NAME} PRIVATE ) target_link_libraries(${EXECUTABLE_NAME} PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/${OS_NAME}/libgamematrix.a + # ${CMAKE_CURRENT_LIST_DIR}/${OS_NAME}/libgamematrix.a ${CMAKE_CURRENT_LIST_DIR}/${OS_NAME}/libraylib.a ) if (WIN32) From c3dc997071b190d24b965f9fa83e44e922341d22 Mon Sep 17 00:00:00 2001 From: graapka99558 Date: Mon, 17 Nov 2025 14:10:13 +0100 Subject: [PATCH 5/7] Gamematrix erstellt --- src/gamematrix.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/gamematrix.cpp b/src/gamematrix.cpp index e69de29..ae65a96 100644 --- a/src/gamematrix.cpp +++ b/src/gamematrix.cpp @@ -0,0 +1,36 @@ +#include "gamematrix.h" +#include + +namespace Matrix3D { + + Mat4 identity() { + Mat4 m{}; + for(int i = 0; i < 4; i++) { + for(int j = 0; j < 4; j++) { + m[i][j] = (i == j) ? 1.0 : 0.0; + } + } + return m; + } + + Mat4 matmul(const Mat4& A, const Mat4& B) { + Mat4 R{}; + for(int i = 0; i < 4; i++) { + for(int j = 0; j < 4; j++) { + double sum = 0.0; + for(int k = 0; k < 4; k++) { + sum += A[i][k] * B[k][j]; + } + R[i][j] = sum; + } + } + return R; + } + + Mat4 translate(const Vec3& pos) { + Mat4 t = identity(); + t[0][3] = pos.x; + t[1][3] = pos.y; + t[2][3] = pos.z; + return t; + } From 00bb22347f125c99d500b62757f6ad150a26595f Mon Sep 17 00:00:00 2001 From: graapka99558 Date: Mon, 17 Nov 2025 14:12:14 +0100 Subject: [PATCH 6/7] Gamematrix erstellt 2 --- src/gamematrix.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/gamematrix.cpp b/src/gamematrix.cpp index ae65a96..5fccbe3 100644 --- a/src/gamematrix.cpp +++ b/src/gamematrix.cpp @@ -34,3 +34,43 @@ namespace Matrix3D { t[2][3] = pos.z; return t; } + + Mat4 rot3D(double angle_deg, char axis) { + Mat4 r = identity(); + + double rad = angle_deg * M_PI / 180.0; + double c = std::cos(rad); + double s = std::sin(rad); + + switch(axis) { + case 'x': case 'X': + r[1][1] = c; r[1][2] = -s; + r[2][1] = s; r[2][2] = c; + break; + + case 'y': case 'Y': + r[0][0] = c; r[0][2] = s; + r[2][0] = -s; r[2][2] = c; + break; + + case 'z': case 'Z': + r[0][0] = c; r[0][1] = -s; + r[1][0] = s; r[1][1] = c; + break; + } + return r; + } + + Vec3 operator*(const Mat4& M, const Vec3& v) { + Vec3 out; + out.x = M[0][0]*v.x + M[0][1]*v.y + M[0][2]*v.z + M[0][3]; + out.y = M[1][0]*v.x + M[1][1]*v.y + M[1][2]*v.z + M[1][3]; + out.z = M[2][0]*v.x + M[2][1]*v.y + M[2][2]*v.z + M[2][3]; + return out; + } + + Mat4 operator*(const Mat4& A, const Mat4& B) { + return matmul(A, B); + } + +} \ No newline at end of file From 7a3481014597efd2269bc28df81a91289e706b3c Mon Sep 17 00:00:00 2001 From: graapka99558 Date: Mon, 17 Nov 2025 14:20:13 +0100 Subject: [PATCH 7/7] gamematrix.h included --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 287251d..000aad8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ #include "gamecube.h" +#include "gamematrix.h" #include #include