#include "gamematrix.h" #include // Entfernt: namespace Matrix3D { ... } <-- GEÄNDERT // Implementierungen jetzt als Klassenmethoden von gameMatrix <-- GEÄNDERT // Optional: identity() als Hilfsmethode hinzugefügt static std::array,4> identity() { // <-- NEU std::array,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,4> gameMatrix::matmul( // <-- GEÄNDERT const std::array,4>& A, const std::array,4>& B) { std::array,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,4> gameMatrix::translate( // <-- GEÄNDERT const std::array& 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,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; }