Merge branch 'developer'

This commit is contained in:
Kai Graap 2025-11-17 14:28:19 +01:00
commit ff5ec85747
4 changed files with 152 additions and 4 deletions

View File

@ -37,7 +37,7 @@ target_include_directories(${EXECUTABLE_NAME} PRIVATE
) )
target_link_libraries(${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 ${CMAKE_CURRENT_LIST_DIR}/${OS_NAME}/libraylib.a
) )
if (WIN32) 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.
========================================================

View File

@ -1,3 +1,76 @@
// #include "gamematrix.h"
// Created by kmust on 03.11.2025. #include <cmath>
//
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;
}
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);
}
}

View File

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