Compare commits
No commits in common. "main" and "developer" have entirely different histories.
@ -1,60 +0,0 @@
|
|||||||
========================================================
|
|
||||||
Projekt: gamematrix (C++ Library)
|
|
||||||
Rolle: Projektleiter
|
|
||||||
Datei: requirements.txt
|
|
||||||
Datum: 3.11.2025
|
|
||||||
Team: Thomas und Co
|
|
||||||
========================================================
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 1. Projektziel
|
|
||||||
# ----------------------------
|
|
||||||
Beschreiben Sie hier kurz das Ziel des Projekts:
|
|
||||||
|
|
||||||
Ziel: Implementierung der Matrixmulitplikation, -Rotation, -Verschiebung und anschließendes Testen
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 2. Funktionale Anforderungen
|
|
||||||
# ----------------------------
|
|
||||||
Listen Sie alle Funktionen auf, die die Bibliothek bereitstellen soll.
|
|
||||||
Tragen Sie ein: Funktion, Eingabe, Ausgabe, kurze Beschreibung
|
|
||||||
|
|
||||||
| Funktion | Eingabe | Ausgabe | Kurzbeschreibung |
|
|
||||||
|---------------|------------------------------------|-----------------------|----------------------------------------|
|
|
||||||
| matmul | 4x4 Matrix A, 4x4 Matrix B | 4x4 Matrix | Multiplikation zweier Matrizen wie in Mathe gelernt
|
|
||||||
| translate | 3D Vektor | 4x4 Matrix | Verschiebung
|
|
||||||
| rot3D | Winkel in °, Rotationsachse (x/y/z)| 4x4 Matrix | Rotation
|
|
||||||
| identity (optional)| --- | 4x4 Matrix | _____________________________________ |
|
|
||||||
| _____________ | __________________________________ | ____________________ | ______________________________ |
|
|
||||||
| _____________ | __________________________________ | ____________________ | ______________________________ |
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 3. Nicht-funktionale Anforderungen
|
|
||||||
# ----------------------------
|
|
||||||
(z. B. Performance, Lesbarkeit, Wartbarkeit, Python-Kompatibilität via pybind11)
|
|
||||||
|
|
||||||
- Lesbarkeit nach Coding Guidelines: https://elearning.ohmportal.de/pluginfile.php/395279/mod_page/content/5/Coding_Guidelines.pdf
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 4. Annahmen / Einschränkungen
|
|
||||||
# ----------------------------
|
|
||||||
(z. B. alle Matrizen sind 4x4, Winkel in Grad, nur double)
|
|
||||||
|
|
||||||
- alle Matrizen sind 4x4
|
|
||||||
- Winkel in Grad
|
|
||||||
- nur double
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 5. Abnahmekriterien
|
|
||||||
# ----------------------------
|
|
||||||
Wie soll geprüft werden, dass die Anforderungen erfüllt sind?
|
|
||||||
(z. B. Unit-Tests, Beispielrotationen, Matrizenmultiplikation)
|
|
||||||
|
|
||||||
- Tests von Marco müssen fehlerfrei verlaufen
|
|
||||||
|
|
||||||
========================================================
|
|
||||||
Hinweis:
|
|
||||||
- Diese Datei wird vom Projektleiter erstellt und gepflegt.
|
|
||||||
- Jede Phase des Projekts soll hier dokumentiert werden.
|
|
||||||
========================================================
|
|
||||||
137
docs/tests.cpp
137
docs/tests.cpp
@ -1,137 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by marco on 03.11.2025.
|
|
||||||
// Changeb by marco on 16.11.2025
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include "gamematrix.h"
|
|
||||||
|
|
||||||
using namespace Matrix3D;
|
|
||||||
|
|
||||||
bool nearlyEqual(double a, double b, double eps = 1e-6) {
|
|
||||||
return std::abs(a - b) < eps;
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_matmul_identity() {
|
|
||||||
Mat4 A = identity();
|
|
||||||
Mat4 B = identity();
|
|
||||||
Mat4 R = matmul(A, B);
|
|
||||||
|
|
||||||
std::cout << "Test matmul: Identity * Identity -> Identity: ";
|
|
||||||
|
|
||||||
bool ok = true;
|
|
||||||
for(int i=0;i<4;i++){
|
|
||||||
for(int j=0;j<4;j++){
|
|
||||||
double expected = (i==j ? 1.0 : 0.0);
|
|
||||||
if(!nearlyEqual(R[i][j], expected)) ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << (ok ? "OK\n" : "FAIL\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_matmul_example() {
|
|
||||||
Mat4 A = {{
|
|
||||||
{{1, 2, 3, 4}},
|
|
||||||
{{0, 1, 2, 3}},
|
|
||||||
{{0, 0, 1, 2}},
|
|
||||||
{{0, 0, 0, 1}}
|
|
||||||
}};
|
|
||||||
|
|
||||||
Mat4 B = {{
|
|
||||||
{{1, 0, 0, 0}},
|
|
||||||
{{1, 1, 0, 0}},
|
|
||||||
{{1, 1, 1, 0}},
|
|
||||||
{{1, 1, 1, 1}}
|
|
||||||
}};
|
|
||||||
|
|
||||||
Mat4 R = matmul(A, B);
|
|
||||||
|
|
||||||
std::cout << "Test matmul: Beispielmatrizen A * B: ";
|
|
||||||
|
|
||||||
// Erwartete Matrix mit Handrechnung:
|
|
||||||
Mat4 Expected = {{
|
|
||||||
{{1+2+3+4, 2+3+4, 3+4, 4}},
|
|
||||||
{{0+1+2+3, 1+2+3, 2+3, 3}},
|
|
||||||
{{0+0+1+2, 0+1+2, 1+2, 2}},
|
|
||||||
{{1, 1, 1, 1}}
|
|
||||||
}};
|
|
||||||
|
|
||||||
bool ok = true;
|
|
||||||
for(int i=0;i<4;i++){
|
|
||||||
for(int j=0;j<4;j++){
|
|
||||||
if(!nearlyEqual(R[i][j], Expected[i][j])) ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << (ok ? "OK\n" : "FAIL\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_translate() {
|
|
||||||
Vec3 v{1,2,3};
|
|
||||||
Mat4 T = translate({5,-2,1});
|
|
||||||
Vec3 out = T * v;
|
|
||||||
|
|
||||||
std::cout << "Test translate (Vec3{1,2,3} + {5,-2,1}): ";
|
|
||||||
|
|
||||||
if(nearlyEqual(out.x, 6) && nearlyEqual(out.y, 0) && nearlyEqual(out.z, 4))
|
|
||||||
std::cout << "OK\n";
|
|
||||||
else
|
|
||||||
std::cout << "FAIL (" << out.x << "," << out.y << "," << out.z << ")\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_rotZ_90() {
|
|
||||||
Vec3 v{1,0,0};
|
|
||||||
Mat4 Rm = rot3D(90, 'z');
|
|
||||||
Vec3 out = Rm * v;
|
|
||||||
|
|
||||||
std::cout << "Test rot3D Z 90° (1,0,0 -> 0,1,0): ";
|
|
||||||
|
|
||||||
if(nearlyEqual(out.x, 0) && nearlyEqual(out.y, 1))
|
|
||||||
std::cout << "OK\n";
|
|
||||||
else
|
|
||||||
std::cout << "FAIL (" << out.x << "," << out.y << "," << out.z << ")\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_rotX_180() {
|
|
||||||
Vec3 v{0,1,0};
|
|
||||||
Mat4 Rm = rot3D(180, 'x');
|
|
||||||
Vec3 out = Rm * v;
|
|
||||||
|
|
||||||
std::cout << "Test rot3D X 180° (0,1,0 -> 0,-1,0): ";
|
|
||||||
|
|
||||||
if(nearlyEqual(out.y, -1))
|
|
||||||
std::cout << "OK\n";
|
|
||||||
else
|
|
||||||
std::cout << "FAIL (" << out.x << "," << out.y << "," << out.z << ")\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_rotY_270() {
|
|
||||||
Vec3 v{1,0,0};
|
|
||||||
Mat4 Rm = rot3D(270, 'y');
|
|
||||||
Vec3 out = Rm * v;
|
|
||||||
|
|
||||||
std::cout << "Test rot3D Y 270° (1,0,0 -> 0,0,-1): ";
|
|
||||||
|
|
||||||
if(nearlyEqual(out.x, 0) && nearlyEqual(out.z, -1))
|
|
||||||
std::cout << "OK\n";
|
|
||||||
else
|
|
||||||
std::cout << "FAIL (" << out.x << "," << out.y << "," << out.z << ")\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
std::cout << "===== Matrix3D Tests =====\n";
|
|
||||||
|
|
||||||
test_matmul_identity();
|
|
||||||
test_matmul_example();
|
|
||||||
|
|
||||||
test_translate();
|
|
||||||
|
|
||||||
test_rotZ_90();
|
|
||||||
test_rotX_180();
|
|
||||||
test_rotY_270();
|
|
||||||
|
|
||||||
std::cout << "==========================\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
========================================================
|
|
||||||
Projekt: gamematrix (C++ Library)
|
|
||||||
Rolle: Tester
|
|
||||||
Datei: tests.txt
|
|
||||||
Datum: ____________________
|
|
||||||
Team: ____________________
|
|
||||||
========================================================
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 1. Testplan Übersicht
|
|
||||||
# ----------------------------
|
|
||||||
Ziel: Überprüfung der Funktionen matmul(), translate(), rot3D().
|
|
||||||
|
|
||||||
| Funktion | Testfall | Eingabe | Erwartetes Ergebnis | Bemerkung |
|
|
||||||
|---------------|---------------------------|------------------------------|-----------------------------------|----------------------------|
|
|
||||||
| matmul | Identity * Identity | 4x4 Identity Matrizen | Identity | Basisfall |
|
|
||||||
| matmul | Beispielmatrizen | A=[[...]], B=[[...]] | C=[[...]] | Prüfen mit Handrechnung |
|
|
||||||
| translate | Verschiebung | Vec3 {1,2,3} | Matrix mit Translation 1,2,3 | Prüfen letzte Spalte |
|
|
||||||
| rot3D | Rotation Z 90° | angle_deg=90, axis='z' | (1,0,0) -> (0,1,0) | Prüfen Anwendung auf Vektor|
|
|
||||||
| rot3D | Rotation X 180° | angle_deg=180, axis='x' | (0,1,0) -> (0,-1,0) | Prüfen Anwendung auf Vektor|
|
|
||||||
| rot3D | Rotation Y 270° | angle_deg=270, axis='y' | (1,0,0) -> (0,0,-1) | Prüfen Anwendung auf Vektor|
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 2. Testdaten / Matrizen
|
|
||||||
# ----------------------------
|
|
||||||
- Matrizen für matmul: Identity, Beispiel A/B Matrizen
|
|
||||||
- Vektoren für translate: Vec3 {x, y, z}
|
|
||||||
- Vektoren für rot3D: Vec3 {1,0,0}, Vec3 {0,1,0}
|
|
||||||
|
|
||||||
# ----------------------------
|
|
||||||
# 3. Abnahmekriterien
|
|
||||||
# ----------------------------
|
|
||||||
- Alle Unit-Tests erfolgreich
|
|
||||||
- Keine Exceptions außer gewollt (z. B. ungültige Achse)
|
|
||||||
- Testbericht in tests.txt dokumentiert
|
|
||||||
|
|
||||||
========================================================
|
|
||||||
Hinweis:
|
|
||||||
- Diese Datei wird vom Tester gepflegt.
|
|
||||||
- Tester dokumentiert Input, Output, erwartetes Ergebnis und Erfolg/Fehler.
|
|
||||||
========================================================
|
|
||||||
@ -2,9 +2,6 @@
|
|||||||
#include "gamematrix.h"
|
#include "gamematrix.h"
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include <rlgl.h>
|
#include <rlgl.h>
|
||||||
#include <array>
|
|
||||||
|
|
||||||
using Mat4 = std::array<std::array<double, 4>, 4>;
|
|
||||||
|
|
||||||
struct Vec3
|
struct Vec3
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "gamecube.h"
|
|
||||||
|
|
||||||
class gameMatrix
|
class gameMatrix
|
||||||
{
|
{
|
||||||
|
|||||||
122
src/gamecube.cpp
122
src/gamecube.cpp
@ -1,70 +1,70 @@
|
|||||||
#include "gamecube.h"
|
#include "gamecube.h"
|
||||||
|
|
||||||
gamecube::gamecube(const Vec3 &pos, Color col)
|
gamecube::gamecube(const Vec3 &pos, Color col)
|
||||||
: position(pos), color(col) {}
|
: position(pos), color(col) {}
|
||||||
|
|
||||||
void gamecube::Update(float flipSpeed)
|
void gamecube::Update(float flipSpeed)
|
||||||
|
{
|
||||||
|
//Tom: Added vars for clarity; replaced old 180.0f, 0.0f
|
||||||
|
const float MaxRotationAngle = 180.0f;
|
||||||
|
const float NoRotationAngle = 0.0f;
|
||||||
|
|
||||||
|
if (flippingForward)
|
||||||
{
|
{
|
||||||
//Tom: Added vars for clarity; replaced old 180.0f, 0.0f
|
rotation += flipSpeed;
|
||||||
const float MaxRotationAngle = 180.0f;
|
if (rotation >= MaxRotationAngle)
|
||||||
const float NoRotationAngle = 0.0f;
|
|
||||||
|
|
||||||
if (flippingForward)
|
|
||||||
{
|
{
|
||||||
rotation += flipSpeed;
|
rotation = MaxRotationAngle;
|
||||||
if (rotation >= MaxRotationAngle)
|
flippingForward = false;
|
||||||
{
|
flipped = true;
|
||||||
rotation = MaxRotationAngle;
|
|
||||||
flippingForward = false;
|
|
||||||
flipped = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (flippingBackward)
|
|
||||||
{
|
|
||||||
rotation -= flipSpeed;
|
|
||||||
if (rotation <= NoRotationAngle)
|
|
||||||
{
|
|
||||||
rotation = NoRotationAngle;
|
|
||||||
flippingBackward = false;
|
|
||||||
flipped = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (flippingBackward)
|
||||||
void gamecube::FlipForward() { flippingForward = true; }
|
|
||||||
void gamecube::FlipBackward() { flippingBackward = true; }
|
|
||||||
|
|
||||||
bool gamecube::IsFlipped() const { return flipped; }
|
|
||||||
bool gamecube::IsMatched() const { return matched; }
|
|
||||||
void gamecube::SetMatched(bool m) { matched = m; }
|
|
||||||
|
|
||||||
void gamecube::Draw() const
|
|
||||||
{
|
{
|
||||||
rlPushMatrix();
|
rotation -= flipSpeed;
|
||||||
|
if (rotation <= NoRotationAngle)
|
||||||
// Matrizen für Rotation und Translation erzeugen
|
{
|
||||||
auto matrix_a = gameMatrix::translate({ position.x, position.y, position.z});
|
rotation = NoRotationAngle;
|
||||||
auto matrix_b = gameMatrix::rot3D(rotation, 'y');
|
flippingBackward = false;
|
||||||
|
flipped = false;
|
||||||
// Matrizen multiplizieren (Translation * Rotation)
|
}
|
||||||
auto model = gameMatrix::matmul(matrix_a, matrix_b);
|
|
||||||
|
|
||||||
// transform for raylib matrix
|
|
||||||
float f[16];
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
for (int j = 0; j < 4; j++)
|
|
||||||
f[j * 4 + i] = model[i][j];
|
|
||||||
rlMultMatrixf(f);
|
|
||||||
|
|
||||||
if (rotation < 90.0f)
|
|
||||||
DrawCube({0,0,0}, 1,1,1, GRAY);
|
|
||||||
else
|
|
||||||
DrawCube({0,0,0}, 1,1,1, color);
|
|
||||||
|
|
||||||
DrawCubeWires({0,0,0}, 1,1,1, BLACK);
|
|
||||||
|
|
||||||
rlPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vec3 gamecube::GetPosition() const { return position; }
|
void gamecube::FlipForward() { flippingForward = true; }
|
||||||
float gamecube::GetRotationY() const { return rotation; }
|
void gamecube::FlipBackward() { flippingBackward = true; }
|
||||||
|
|
||||||
|
bool gamecube::IsFlipped() const { return flipped; }
|
||||||
|
bool gamecube::IsMatched() const { return matched; }
|
||||||
|
void gamecube::SetMatched(bool m) { matched = m; }
|
||||||
|
|
||||||
|
void gamecube::Draw() const
|
||||||
|
{
|
||||||
|
rlPushMatrix();
|
||||||
|
|
||||||
|
// Matrizen für Rotation und Translation erzeugen
|
||||||
|
auto matrix_a = gameMatrix::translate({ position.x, position.y, position.z});
|
||||||
|
auto matrix_b = gameMatrix::rot3D(rotation, 'y');
|
||||||
|
|
||||||
|
// Matrizen multiplizieren (Translation * Rotation)
|
||||||
|
auto model = gameMatrix::matmul(matrix_a, matrix_b);
|
||||||
|
|
||||||
|
// transform for raylib matrix
|
||||||
|
float f[16];
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
for (int j = 0; j < 4; j++)
|
||||||
|
f[j * 4 + i] = model[i][j];
|
||||||
|
rlMultMatrixf(f);
|
||||||
|
|
||||||
|
if (rotation < 90.0f)
|
||||||
|
DrawCube({0,0,0}, 1,1,1, GRAY);
|
||||||
|
else
|
||||||
|
DrawCube({0,0,0}, 1,1,1, color);
|
||||||
|
|
||||||
|
DrawCubeWires({0,0,0}, 1,1,1, BLACK);
|
||||||
|
|
||||||
|
rlPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
Vec3 gamecube::GetPosition() const { return position; }
|
||||||
|
float gamecube::GetRotationY() const { return rotation; }
|
||||||
@ -1,75 +1,76 @@
|
|||||||
#include "gamematrix.h"
|
#include "gamematrix.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
// Entfernt: namespace Matrix3D { ... } <-- GEÄNDERT
|
namespace Matrix3D {
|
||||||
|
|
||||||
// Implementierungen jetzt als Klassenmethoden von gameMatrix <-- GEÄNDERT
|
Mat4 identity() {
|
||||||
|
Mat4 m{};
|
||||||
// Optional: identity() als Hilfsmethode hinzugefügt
|
for(int i = 0; i < 4; i++) {
|
||||||
static std::array<std::array<double,4>,4> identity() { // <-- NEU
|
for(int j = 0; j < 4; j++) {
|
||||||
std::array<std::array<double,4>,4> m{};
|
m[i][j] = (i == j) ? 1.0 : 0.0;
|
||||||
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<std::array<double,4>,4> gameMatrix::matmul( // <-- GEÄNDERT
|
|
||||||
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> 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 m;
|
||||||
}
|
}
|
||||||
return R;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------- translate --------------------
|
Mat4 matmul(const Mat4& A, const Mat4& B) {
|
||||||
std::array<std::array<double,4>,4> gameMatrix::translate( // <-- GEÄNDERT
|
Mat4 R{};
|
||||||
const std::array<double,3>& pos)
|
for(int i = 0; i < 4; i++) {
|
||||||
{
|
for(int j = 0; j < 4; j++) {
|
||||||
auto t = identity(); // <-- NEU: nutzt die Hilfsmethode
|
double sum = 0.0;
|
||||||
t[0][3] = pos[0];
|
for(int k = 0; k < 4; k++) {
|
||||||
t[1][3] = pos[1];
|
sum += A[i][k] * B[k][j];
|
||||||
t[2][3] = pos[2];
|
}
|
||||||
return t;
|
R[i][j] = sum;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return R;
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------- rot3D --------------------
|
Mat4 translate(const Vec3& pos) {
|
||||||
std::array<std::array<double,4>,4> gameMatrix::rot3D( // <-- GEÄNDERT
|
Mat4 t = identity();
|
||||||
double angle_deg, char axis)
|
t[0][3] = pos.x;
|
||||||
{
|
t[1][3] = pos.y;
|
||||||
auto r = identity(); // <-- NEU: nutzt die Hilfsmethode
|
t[2][3] = pos.z;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
double rad = angle_deg * M_PI / 180.0;
|
Mat4 rot3D(double angle_deg, char axis) {
|
||||||
double c = std::cos(rad);
|
Mat4 r = identity();
|
||||||
double s = std::sin(rad);
|
|
||||||
|
|
||||||
switch(axis) {
|
double rad = angle_deg * M_PI / 180.0;
|
||||||
case 'x': case 'X':
|
double c = std::cos(rad);
|
||||||
r[1][1] = c; r[1][2] = -s;
|
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;
|
r[2][1] = s; r[2][2] = c;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'y': case 'Y':
|
case 'y': case 'Y':
|
||||||
r[0][0] = c; r[0][2] = s;
|
r[0][0] = c; r[0][2] = s;
|
||||||
r[2][0] = -s; r[2][2] = c;
|
r[2][0] = -s; r[2][2] = c;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'z': case 'Z':
|
case 'z': case 'Z':
|
||||||
r[0][0] = c; r[0][1] = -s;
|
r[0][0] = c; r[0][1] = -s;
|
||||||
r[1][0] = s; r[1][1] = c;
|
r[1][0] = s; r[1][1] = c;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
return r;
|
|
||||||
|
Vec3 operator*(const Mat4& M, const Vec3& v) {
|
||||||
|
Vec3 out;
|
||||||
|
out.x = M[0][0]*v.x + M[0][1]*v.y + M[0][2]*v.z + M[0][3];
|
||||||
|
out.y = M[1][0]*v.x + M[1][1]*v.y + M[1][2]*v.z + M[1][3];
|
||||||
|
out.z = M[2][0]*v.x + M[2][1]*v.y + M[2][2]*v.z + M[2][3];
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mat4 operator*(const Mat4& A, const Mat4& B) {
|
||||||
|
return matmul(A, B);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user