diff --git a/src/gamematrix.cpp b/src/gamematrix.cpp new file mode 100644 index 0000000..ad99c98 --- /dev/null +++ b/src/gamematrix.cpp @@ -0,0 +1,77 @@ +#include + + +static std::array,4> gameMatrix::matmul(const std::array,4>& A, + const std::array,4>& B);{ + std::array,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; +} + + +static std::array,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,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; +} + +static std::array,4> gameMatrix::translate(const std::array& pos); +{ + std::array,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. +// \ No newline at end of file