Compare commits
No commits in common. "fba740c35c96640dff1784aeb385c8454f3c8da8" and "28041fcf9f514e57a6e93ea190cc0a53d5c5e6aa" have entirely different histories.
fba740c35c
...
28041fcf9f
@ -1,75 +0,0 @@
|
|||||||
#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.
|
|
||||||
//
|
|
||||||
Loading…
x
Reference in New Issue
Block a user