66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
//Ablage für ChatGPT Sachen, nicht relavant für das Projekt (Nur ein "Cloud"-Zwischenspeicher)
|
|
#include <iostream>
|
|
#include <array>
|
|
#include <string>
|
|
#include <cmath>
|
|
|
|
// Typalias für 4x4-Matrix mit double
|
|
#include "gamematrix.h"
|
|
// Matrixmultiplikation
|
|
static std::array<std::array<double,4>,4> matmul(const std::array<std::array<double,4>,4>& A,
|
|
const std::array<std::array<double,4>,4>& B);
|
|
|
|
// Rotationsmatrix um Achse x/y/z
|
|
static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis);
|
|
|
|
// Verschiebung
|
|
static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos);
|
|
|
|
|
|
//Mathematische Funkion, Rechnung (Matrix C = A*B)
|
|
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> C{};
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int j = 0; j < 4; ++j)
|
|
for (int k = 0; k < 4; ++k)
|
|
C[i][j] += A[i][k] * B[k][j];
|
|
|
|
return C;
|
|
}
|
|
|
|
|
|
int main()
|
|
{
|
|
std::array<std::array<double,4>,4> A{};
|
|
std::array<std::array<double,4>,4> B{};
|
|
|
|
std::cout << "Gib die Werte für Matrix A (4x4) ein:\n";
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int j = 0; j < 4; ++j) {
|
|
std::cout << "A[" << i << "][" << j << "] = ";
|
|
std::cin >> A[i][j];
|
|
}
|
|
|
|
std::cout << "\nGib die Werte für Matrix B (4x4) ein:\n";
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int j = 0; j < 4; ++j) {
|
|
std::cout << "B[" << i << "][" << j << "] = ";
|
|
std::cin >> B[i][j];
|
|
}
|
|
|
|
auto C = gameMatrix::matmul(A, B);
|
|
|
|
std::cout << "\nErgebnis der Matrixmultiplikation (C = A * B):\n";
|
|
for (int i = 0; i < 4; ++i) {
|
|
for (int j = 0; j < 4; ++j)
|
|
std::cout << C[i][j] << "\t";
|
|
std::cout << "\n";
|
|
}
|
|
|
|
return 0;
|
|
}
|