Compare commits

...

15 Commits

Author SHA1 Message Date
8eda60d498 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	CMakeLists.txt
2025-11-17 15:14:36 +01:00
69dfbdf139 Funktionsfähig gemacht 2025-11-17 15:13:47 +01:00
16e918b180 includes 2025-11-17 14:58:28 +01:00
48903fdf01 hinzugefügt cmake:current 2025-11-17 14:58:17 +01:00
6e2119ab01 Merge branch 'project_tests' 2025-11-17 14:29:53 +01:00
ff5ec85747 Merge branch 'developer' 2025-11-17 14:28:19 +01:00
4bc2574c03 Merge branch 'project_leader' 2025-11-17 14:26:09 +01:00
7a34810145 gamematrix.h included 2025-11-17 14:20:13 +01:00
00bb22347f Gamematrix erstellt 2 2025-11-17 14:12:14 +01:00
c3dc997071 Gamematrix erstellt 2025-11-17 14:10:13 +01:00
a561b26425 CMake angepasst 2025-11-03 15:24:49 +01:00
96a19a6312 Design.txt Änderungen 2025-11-03 15:21:44 +01:00
0c71e3d2c7 Docs Design 2025-11-03 15:10:58 +01:00
5ff1281385 Docs Design + Gamematrix 2025-11-03 15:04:36 +01:00
d3ce2aa5f8 added folder docs/requirements.txt 2025-11-03 14:57:55 +01:00
8 changed files with 276 additions and 66 deletions

View File

@ -19,7 +19,6 @@ 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
@ -38,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)

74
docs/design.txt Normal file
View File

@ -0,0 +1,74 @@
========================================================
Projekt: gamematrix (C++ Library)
Rolle: Architekt
Datei: design.txt
Datum: 03-November
Team: Thomas&Co
========================================================
# ----------------------------
# 1. Projektstruktur / Namespace
# ----------------------------
Namespace: Matrix3D
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<std::array<double,4>,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.
========================================================

60
docs/requirements.txt Normal file
View File

@ -0,0 +1,60 @@
========================================================
Projekt: gamematrix (C++ Library)
Rolle: Projektleiter
Datei: requirements.txt
Datum: 3.11.2025
Team: Thomas und Co
========================================================
# ----------------------------
# 1. Projektziel
# ----------------------------
Beschreiben Sie hier kurz das Ziel des Projekts:
Ziel: Implementierung der Matrixmulitplikation, -Rotation, -Verschiebung und anschließendes Testen
# ----------------------------
# 2. Funktionale Anforderungen
# ----------------------------
Listen Sie alle Funktionen auf, die die Bibliothek bereitstellen soll.
Tragen Sie ein: Funktion, Eingabe, Ausgabe, kurze Beschreibung
| Funktion | Eingabe | Ausgabe | Kurzbeschreibung |
|---------------|------------------------------------|-----------------------|----------------------------------------|
| matmul | 4x4 Matrix A, 4x4 Matrix B | 4x4 Matrix | Multiplikation zweier Matrizen wie in Mathe gelernt
| translate | 3D Vektor | 4x4 Matrix | Verschiebung
| rot3D | Winkel in °, Rotationsachse (x/y/z)| 4x4 Matrix | Rotation
| identity (optional)| --- | 4x4 Matrix | _____________________________________ |
| _____________ | __________________________________ | ____________________ | ______________________________ |
| _____________ | __________________________________ | ____________________ | ______________________________ |
# ----------------------------
# 3. Nicht-funktionale Anforderungen
# ----------------------------
(z. B. Performance, Lesbarkeit, Wartbarkeit, Python-Kompatibilität via pybind11)
- Lesbarkeit nach Coding Guidelines: https://elearning.ohmportal.de/pluginfile.php/395279/mod_page/content/5/Coding_Guidelines.pdf
# ----------------------------
# 4. Annahmen / Einschränkungen
# ----------------------------
(z. B. alle Matrizen sind 4x4, Winkel in Grad, nur double)
- alle Matrizen sind 4x4
- Winkel in Grad
- nur double
# ----------------------------
# 5. Abnahmekriterien
# ----------------------------
Wie soll geprüft werden, dass die Anforderungen erfüllt sind?
(z. B. Unit-Tests, Beispielrotationen, Matrizenmultiplikation)
- Tests von Marco müssen fehlerfrei verlaufen
========================================================
Hinweis:
- Diese Datei wird vom Projektleiter erstellt und gepflegt.
- Jede Phase des Projekts soll hier dokumentiert werden.
========================================================

View File

@ -2,6 +2,9 @@
#include "gamematrix.h"
#include "raylib.h"
#include <rlgl.h>
#include <array>
using Mat4 = std::array<std::array<double, 4>, 4>;
struct Vec3
{

View File

@ -3,6 +3,7 @@
#include <array>
#include <stdexcept>
#include <cmath>
#include "gamecube.h"
class gameMatrix
{

View File

@ -1,3 +1,75 @@
//
// Created by kmust on 03.11.2025.
//
#include "gamematrix.h"
#include <cmath>
// Entfernt: namespace Matrix3D { ... } <-- GEÄNDERT
// Implementierungen jetzt als Klassenmethoden von gameMatrix <-- GEÄNDERT
// Optional: identity() als Hilfsmethode hinzugefügt
static std::array<std::array<double,4>,4> identity() { // <-- NEU
std::array<std::array<double,4>,4> 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;
}
// -------------------- matmul --------------------
std::array<std::array<double,4>,4> gameMatrix::matmul( // <-- GEÄNDERT
const std::array<std::array<double,4>,4>& A,
const std::array<std::array<double,4>,4>& B)
{
std::array<std::array<double,4>,4> 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;
}
// -------------------- translate --------------------
std::array<std::array<double,4>,4> gameMatrix::translate( // <-- GEÄNDERT
const std::array<double,3>& pos)
{
auto t = identity(); // <-- NEU: nutzt die Hilfsmethode
t[0][3] = pos[0];
t[1][3] = pos[1];
t[2][3] = pos[2];
return t;
}
// -------------------- rot3D --------------------
std::array<std::array<double,4>,4> gameMatrix::rot3D( // <-- GEÄNDERT
double angle_deg, char axis)
{
auto r = identity(); // <-- NEU: nutzt die Hilfsmethode
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;
}

View File

@ -1,4 +1,5 @@
#include "gamecube.h"
#include "gamematrix.h"
#include <algorithm>
#include <ctime>