Compare commits
15 Commits
project_te
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8eda60d498 | |||
| 69dfbdf139 | |||
| 16e918b180 | |||
| 48903fdf01 | |||
| 6e2119ab01 | |||
| ff5ec85747 | |||
| 4bc2574c03 | |||
| 7a34810145 | |||
| 00bb22347f | |||
| c3dc997071 | |||
| a561b26425 | |||
| 96a19a6312 | |||
| 0c71e3d2c7 | |||
| 5ff1281385 | |||
| d3ce2aa5f8 |
@ -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
74
docs/design.txt
Normal 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
60
docs/requirements.txt
Normal 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.
|
||||
========================================================
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <array>
|
||||
#include <stdexcept>
|
||||
#include <cmath>
|
||||
#include "gamecube.h"
|
||||
|
||||
class gameMatrix
|
||||
{
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
#include "gamecube.h"
|
||||
#include "gamematrix.h"
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user