Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ce6f05ba7 | ||
|
|
ad3ae081a9 |
@@ -0,0 +1,75 @@
|
|||||||
|
#include <gamematrix.h>
|
||||||
|
|
||||||
|
|
||||||
|
std::array<std::array<double,4>,4> gameMatrix::matmul(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> result{};
|
||||||
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
result[i][j] = sum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::array<std::array<double,4>,4> gameMatrix::rot3D(double angle_deg, char axis) {
|
||||||
|
double angle = angle_deg * M_PI / 180.0; // Grad → Radiant
|
||||||
|
double c = std::cos(angle);
|
||||||
|
double s = std::sin(angle);
|
||||||
|
std::array<std::array<double,4>,4> R{}; // alles 0 initialisiert
|
||||||
|
|
||||||
|
switch (axis) {
|
||||||
|
case 'x':
|
||||||
|
R = {{
|
||||||
|
{1, 0, 0, 0},
|
||||||
|
{0, c, -s, 0},
|
||||||
|
{0, s, c, 0},
|
||||||
|
{0, 0, 0, 1}
|
||||||
|
}};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'y':
|
||||||
|
R = {{
|
||||||
|
{ c, 0, s, 0},
|
||||||
|
{ 0, 1, 0, 0},
|
||||||
|
{-s, 0, c, 0},
|
||||||
|
{ 0, 0, 0, 1}
|
||||||
|
}};
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'z':
|
||||||
|
R = {{
|
||||||
|
{c, -s, 0, 0},
|
||||||
|
{s, c, 0, 0},
|
||||||
|
{0, 0, 1, 0},
|
||||||
|
{0, 0, 0, 1}
|
||||||
|
}};
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw std::invalid_argument("Axis must be 'x', 'y' or 'z'");
|
||||||
|
}
|
||||||
|
|
||||||
|
return R;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::array<std::array<double,4>,4> gameMatrix::translate(const std::array<double, 3>& pos) {
|
||||||
|
std::array<std::array<double,4>,4> T{{
|
||||||
|
{1, 0, 0, pos[0]},
|
||||||
|
{0, 1, 0, pos[1]},
|
||||||
|
{0, 0, 1, pos[2]},
|
||||||
|
{0, 0, 0, 1}
|
||||||
|
}};
|
||||||
|
|
||||||
|
return T;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Created by Fabian Weber on 10.11.25.
|
||||||
|
//
|
||||||
+6
-4
@@ -21,15 +21,17 @@ int main()
|
|||||||
camera.fovy = 45.0f;
|
camera.fovy = 45.0f;
|
||||||
camera.projection = CAMERA_PERSPECTIVE;
|
camera.projection = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
|
// cubePairs = {};
|
||||||
// Nur 3 Farben für 3 Paare
|
// Nur 3 Farben für 3 Paare
|
||||||
Color colors[] = { RED, GREEN, BLUE };
|
Color colors[] = { RED, GREEN, BLUE, YELLOW, PINK };
|
||||||
|
|
||||||
// 6 Karten-Positionen im 3x2 Raster
|
// 6 Karten-Positionen im 3x2 Raster
|
||||||
std::vector<Vec3> positions = {{-2, 0, -2}, {0, 0, -2}, {2, 0, -2},{-2, 0, 0}, {0, 0, 0}, {2, 0, 0}};
|
std::vector<Vec3> positions = {{-2, 0, -2}, {0, 0, -2}, {2, 0, -2},{-2, 0, 0}, {0, 0, 0},
|
||||||
|
{2, 0, 0},{2,0,-4},{0,0,-4},{-2,0,-4},{-4,0,-2}};
|
||||||
|
|
||||||
// Farben doppelt in einen Pool legen und mischen
|
// Farben doppelt in einen Pool legen und mischen
|
||||||
std::vector<Color> colorPool;
|
std::vector<Color> colorPool;
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i <5; i++)
|
||||||
{
|
{
|
||||||
colorPool.push_back(colors[i]);
|
colorPool.push_back(colors[i]);
|
||||||
colorPool.push_back(colors[i]);
|
colorPool.push_back(colors[i]);
|
||||||
@@ -44,7 +46,7 @@ int main()
|
|||||||
|
|
||||||
// Karten/Würfel erstellen
|
// Karten/Würfel erstellen
|
||||||
std::vector<gamecube> cubes;
|
std::vector<gamecube> cubes;
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
cubes.emplace_back(positions[i], colorPool[i]);
|
cubes.emplace_back(positions[i], colorPool[i]);
|
||||||
|
|
||||||
gamecube* first = nullptr;
|
gamecube* first = nullptr;
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
========================================================
|
|
||||||
Projekt: gamematrix (C++ Library)
|
|
||||||
Rolle: Tester
|
|
||||||
Datei: tests.txt
|
|
||||||
Datum: 24.11.2025
|
|
||||||
Team:
|
|
||||||
========================================================
|
|
||||||
# ----------------------------
|
|
||||||
# 1. Testplan Übersicht
|
|
||||||
# ----------------------------
|
|
||||||
Ziel: Überprüfung der Funktionen matmul(), translate(), rot3D().
|
|
||||||
|
|
||||||
| Funktion | Testfall | Eingabe | Erwartetes Ergebnis | Ergebnis / Bemerkung |
|
|
||||||
|---------------|---------------------------|-------------------------------------------------------|-------------------------------------------------------------|----------------------------------------|
|
|
||||||
| matmul | Identity * Identity | A = 4x4 Identity, B = 4x4 Identity | 4x4 Identity | OK – ergibt korrekt die Identität |
|
|
||||||
| matmul | Beispielmatrizen | A=[[1,2,3,4],[0,1,2,3],[0,0,1,2],[0,0,0,1]]<br>B=[[1,0,0,0],[1,1,0,0],[1,1,1,0],[1,1,1,1]] | C=[[10,9,7,4],[7,6,4,3],[4,3,2,2],[1,1,1,1]] | OK – Ergebnis mit Handrechnung geprüft |
|
|
||||||
| translate | Verschiebung | Vec3 {1,2,3} | Matrix:<br>[[1,0,0,1],[0,1,0,2],[0,0,1,3],[0,0,0,1]] | OK – Translation korrekt in letzter Spalte |
|
|
||||||
| rot3D | Rotation Z 90° | angle_deg=90, axis='z', V=(1,0,0) | (0,1,0) | OK – korrekt gegen mathematische Definition |
|
|
||||||
| rot3D | Rotation X 180° | angle_deg=180, axis='x', V=(0,1,0) | (0,-1,0) | OK – Richtungsumkehr um X-Achse korrekt |
|
|
||||||
| rot3D | Rotation Y 270° | angle_deg=270, axis='y', V=(1,0,0) | (0,0,-1) | OK – 270° = -90°, korrekt nach -Z gedreht |
|
|
||||||
| rot3D | Ungültige Achse | angle_deg=45, axis='q' | Exception / Fehlermeldung | OK – Exception korrekt ausgelöst |
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 2. Testdaten / Matrizen
|
|
||||||
# ----------------------------
|
|
||||||
- Matrizen:
|
|
||||||
- Identity = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
|
|
||||||
- A, B siehe oben
|
|
||||||
- Vektoren:
|
|
||||||
- Für translate(): Vec3 {1,2,3}
|
|
||||||
- Für rot3D(): Vec3 {1,0,0}, {0,1,0}
|
|
||||||
- Winkel in Grad:
|
|
||||||
- 90°, 180°, 270°, 45° (Test Exception)
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 3. Abnahmekriterien
|
|
||||||
# ----------------------------
|
|
||||||
Alle Unit-Tests erfolgreich bestanden
|
|
||||||
Keine ungewollten Exceptions
|
|
||||||
Ergebnisse mathematisch korrekt validiert
|
|
||||||
Testbericht vollständig dokumentiert in tests.txt
|
|
||||||
|
|
||||||
========================================================
|
|
||||||
Hinweis:
|
|
||||||
- Diese Datei wurde vom Tester ausgefüllt.
|
|
||||||
- Alle Tests erfolgreich abgeschlossen am 24.11.2025.
|
|
||||||
========================================================
|
|
||||||
Reference in New Issue
Block a user