diff --git a/.gitignore b/.gitignore
index 72371a1..e54bbd0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,2 @@
cmake-build-debug/
-cmake-build-debug-mingw/
-.idea/
\ No newline at end of file
+cmake-build-debug-mingw/
\ No newline at end of file
diff --git a/.idea - Kopie/Programmieren 3B.iml b/.idea - Kopie/Programmieren 3B.iml
index 4c94235..f08604b 100644
--- a/.idea - Kopie/Programmieren 3B.iml
+++ b/.idea - Kopie/Programmieren 3B.iml
@@ -1,2 +1,2 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/.idea - Kopie/editor.xml b/.idea - Kopie/editor.xml
index 5fff85e..b0d69ef 100644
--- a/.idea - Kopie/editor.xml
+++ b/.idea - Kopie/editor.xml
@@ -240,5 +240,244 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea - Kopie/modules.xml b/.idea - Kopie/modules.xml
index bff9f89..3795d21 100644
--- a/.idea - Kopie/modules.xml
+++ b/.idea - Kopie/modules.xml
@@ -2,6 +2,7 @@
+
diff --git a/.idea - Kopie/workspace.xml b/.idea - Kopie/workspace.xml
new file mode 100644
index 0000000..373a5cd
--- /dev/null
+++ b/.idea - Kopie/workspace.xml
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "useNewFormat": true
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "customColor": "",
+ "associatedIndex": 0
+}
+
+
+
+
+
+ {
+ "keyToString": {
+ "CMake Application.Prog3B.executor": "Run",
+ "CMake Application.Prog3B_tests.executor": "Run",
+ "RunOnceActivity.RadMigrateCodeStyle": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.cidr.known.project.marker": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "RunOnceActivity.readMode.enableVisualFormatting": "true",
+ "RunOnceActivity.west.config.association.type.startup.service": "true",
+ "cf.first.check.clang-format": "false",
+ "cidr.known.project.marker": "true",
+ "git-widget-placeholder": "main",
+ "last_opened_file_path": "C:/Users/marce/Desktop/Prog Praktikum C++/Vorlesung/Lambda",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "CMakeSettings",
+ "vue.rearranger.settings.migration": "true"
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1762176441912
+
+
+ 1762176441912
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f411af4..fa4528c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,6 @@ endif()
set(SRC_FILES
${CMAKE_CURRENT_LIST_DIR}/main.cpp
${CMAKE_CURRENT_LIST_DIR}/gamecube.cpp
- tests.cpp
)
set(INCLUDE_DIRS
@@ -49,8 +48,6 @@ endif()
add_executable(${EXECUTABLE_NAME} ${SRC_FILES})
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${INCLUDE_DIRS})
-
-
# === Bibliotheken verlinken ===
target_link_libraries(${EXECUTABLE_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/${OS_DIR}/libgamematrix.a
@@ -71,7 +68,5 @@ if(APPLE)
)
endif()
-
add_executable(Prog3B_tests tests.cpp)
set_target_properties(Prog3B_tests PROPERTIES WIN32_EXECUTABLE OFF)
-
diff --git a/design.txt b/design.txt
deleted file mode 100644
index cdd3d44..0000000
--- a/design.txt
+++ /dev/null
@@ -1,75 +0,0 @@
-========================================================
-Projekt: gamematrix (C++ Library)
-Rolle: Architekt
-Datei: design.txt
-Datum: 03.11
-Team: Stone_Development
-========================================================
-
-# ----------------------------
-# 1. Projektstruktur / Namespace
-# ----------------------------
-Namespace: Matrix3D
-
-Ziel: Saubere Trennung der Bibliothek, Vermeidung von Namenskonflikten.
-
-Beispiel:
-namespace Matrix3D {
- // Funktionen, ggf Klasse(n)
-}
-
-# ----------------------------
-# 2. Datenstrukturen / Klassen
-# ----------------------------
-Listen Sie die Klassen oder Structs auf, die verwendet werden:
-
-| Name | Typ | Beschreibung |
-|--------|------------------------------------------|--------------|
-| Vec3 | struct Vec3 | 3D-Vektor (x, y, z) |
-| Mat4 | std::array,4> | 4x4-Matrix (homogen) |
-| ______ | ________ | ___________________ |
-| ______ | ________ | ___________________ |
-
-# ----------------------------
-# 3. Operatoren / Templates
-# ----------------------------
-Welche Operatoren oder Templates sollen definiert werden?
-
-- Templates für unterschiedliche Datentypen? x Ja
-- Operatoren:
- - Mat4 * Mat4
- - Mat4 * Vec3
-
-# ----------------------------
-# 4. Funktionen / Schnittstellen
-# ----------------------------
-Liste der Funktionen mit Eingabe/Ausgabe und kurzer Beschreibung:
-
-| Funktion | Eingabe | Ausgabe | Kurzbeschreibung |
-|---------------|------------------------------------|-----------------------|----------------------------------------|
-| matmul | Mat4 A, Mat4 B | Mat4 | Matrixmultiplikation 4x4 |
-| translate | Vec3 pos | Mat4 | Verschiebungstransformation |
-| rot3D | double angle_deg, char axis | Mat4 | Rotation um Achse x/y/z | |
-| _____________ | __________________________________ | ____________________ | ______________________________ |
-
-# ----------------------------
-# 5. Designentscheidungen / Hinweise
-# ----------------------------
-- Rückgabe der Matrizen per Wert oder Referenz? Rückgabe
-- Verwendung von std::array oder std::vector? std::array
-- Homogene Koordinaten für Translation / Rotation (4x4)? ☐ Ja
-- Weitere Designüberlegungen: ___________________________
-
-# ----------------------------
-# 6. Deliverables / Milestones
-# ----------------------------
-- design.txt fertig und im Branch architect committed
-- Übergabe an Entwickler für Implementierung
-
-========================================================
-Hinweis:
-- Dieses Dokument dient als Grundlage für die Implementierung.
-- Alle Designentscheidungen sollen klar nachvollziehbar sein.
-========================================================
-
-test
diff --git a/gamecube.cpp b/gamecube.cpp
index 2984581..38573ed 100644
--- a/gamecube.cpp
+++ b/gamecube.cpp
@@ -44,11 +44,11 @@ void gamecube::Draw() const
rlPushMatrix();
// Matrizen für Rotation und Translation erzeugen
- auto matrix_a = Matrix3D::gameMatrix::translate({ position.x, position.y, position.z});
- auto matrix_b = Matrix3D::gameMatrix::rot3D(rotation, 'y');
+ auto matrix_a = gameMatrix::translate({ position.x, position.y, position.z});
+ auto matrix_b = gameMatrix::rot3D(rotation, 'y');
// Matrizen multiplizieren (Translation * Rotation)
- auto model = Matrix3D::gameMatrix::matmul(matrix_a, matrix_b);
+ auto model = gameMatrix::matmul(matrix_a, matrix_b);
// transform for raylib matrix
float f[16];
diff --git a/gamematrix.cpp b/gamematrix.cpp
deleted file mode 100644
index ba1ba4a..0000000
--- a/gamematrix.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "gamematrix.h"
-
-
-using namespace Matrix3D;
-
-///
-/// @param matrix1 - First matrix
-/// @param matrix2 - Second matrix
-/// @return Returns the multiplication of matrix 1 and matrix 2.
-std::array,4> gameMatrix::matmul(const std::array,4>& matrix1,
- const std::array,4>& matrix2) {
-
- std::array,4> matrix3 = {};
- if (matrix1[0].size() != matrix2.size()) {
- throw std::invalid_argument("Number of columns of matrix 1 must be equal to number of rows of matrix 2");
- };
- for (int i = 0; i < matrix1.size(); i++) {
- std::array temp_array = {};
- for (int j = 0; j < matrix2[i].size(); j++) {
- double temp = 0;
- for (int k = 0; k < matrix2.size(); k++) {
- temp += matrix1[i][k] * matrix2[k][j];
- }
- temp_array[j] = temp;
- }
- matrix3[i] = temp_array;
- }
- return matrix3;
-}
-
-///
-/// @param angle_deg Rotation angle
-/// @param axis Rotation axis (x, y, z)
-/// @return Returns a rotation matrix based on a given angle and axis.
-std::array,4> gameMatrix::rot3D(double angle_deg, char axis) {
- if (axis != 'x' && axis != 'y' && axis != 'z') {
- throw std::invalid_argument("Invalid axis");
- };
- const auto angle_rad = angle_deg * M_PI / 180;
- std::array,4> rotationMatrix = {};
- switch (axis) {
- case 'x': {
- std::array,4> rMx = {{
- {1, 0, 0, 0},
- {0, cos(angle_rad), -sin(angle_rad), 0},
- {0, sin(angle_rad), cos(angle_rad), 0},
- {0, 0, 0, 1}
- }};
- rotationMatrix = rMx;
- }
- break;
- case 'y': {
- std::array,4> rMy = {{
- {cos(angle_rad), 0, sin(angle_rad), 0},
- {0, 1, 0, 0},
- {-sin(angle_rad), 0, cos(angle_rad), 0},
- {0, 0, 0, 1}
- }};
- rotationMatrix = rMy;
- }
- break;
-
- case 'z': {
- std::array,4> rMz = {{
- {cos(angle_rad), -sin(angle_rad), 0, 0},
- {sin(angle_rad), cos(angle_rad), 0, 0},
- {0, 0, 1, 0},
- {0, 0, 0, 1}
- }};
- rotationMatrix = rMz;
- }
- break;
- }
- return rotationMatrix;
-};
-
-
-///
-/// @param pos 3 point vector (x, y, z)
-/// @return Returns a 4x4 translation matrix base on a given vector.
-std::array,4> gameMatrix::translate(const std::array& pos) {
- std::array,4> transMatrix = {{{1, 0, 0, pos[0]}, {0, 1, 0, pos[1]}, {0, 0, 1, pos[2]}, {0, 0, 0, 1}}};
- return transMatrix;
-};
-
-
-
diff --git a/gamematrix.h b/gamematrix.h
index db92914..7a644d6 100644
--- a/gamematrix.h
+++ b/gamematrix.h
@@ -4,23 +4,16 @@
#include
#include
-namespace Matrix3D {
- class gameMatrix
- {
- public:
- // Matrix Multiplikation
- static std::array,4> matmul(const std::array,4>& matrix1,
- const std::array,4>& matrix2);
+class gameMatrix
+{
+public:
+ // Matrix Multiplikation
+ static std::array,4> matmul(const std::array,4>& A,
+ const std::array,4>& B);
- // Rotationsmatrix um Achse x/y/z
- static std::array,4> rot3D(double angle_deg, char axis);
+ // Rotationsmatrix um Achse x/y/z
+ static std::array,4> rot3D(double angle_deg, char axis);
- // Verschiebung
- static std::array,4> translate(const std::array& pos);
-
- private:
- //TODO: Was für eine Rolle spielen Vec3 und Mat4???
- struct Vec3 {double x,y,z;};
- std::array,4> Mat4 {};
- };
-}
\ No newline at end of file
+ // Verschiebung
+ static std::array,4> translate(const std::array& pos);
+};
diff --git a/main.cpp b/main.cpp
index 3c56993..9d1abe5 100644
--- a/main.cpp
+++ b/main.cpp
@@ -11,6 +11,7 @@ int main()
//AXIOM WAR HIER
// Zufall initialisieren
srand(time(NULL));
+
// Fenster und Kamera
InitWindow(800, 600, "3D Memory Game with Matrix3D Library");
SetTargetFPS(60);
diff --git a/tests.cpp b/tests.cpp
index fc291e1..b2f16bb 100644
--- a/tests.cpp
+++ b/tests.cpp
@@ -1,13 +1,53 @@
-#include
+#include
+#include
+#include
+#include "gamematrix.h"
-int main()
-{
+void test_matmul_basic() {
+ std::array,4> A = {{
+ {1, 0, 0, 0},
+ {0, 1, 0, 0},
+ {0, 0, 1, 0},
+ {0, 0, 0, 1}
+ }};
+ std::array,4> B = {{
+ {2, 3, 4, 5},
+ {1, 1, 1, 1},
+ {0, 0, 0, 0},
+ {7, 7, 7, 7}
+ }};
+ auto C = gameMatrix::matmul(A, B);
+
+ assert(C[0][0] == 2);
+ assert(C[0][1] == 3);
+ assert(C[1][0] == 1);
+ assert(C[3][3] == 7);
}
-bool test_matmul()
-{
-
+void test_translate_basic() {
+ std::array pos = {3, -2, 8};
-}
\ No newline at end of file
+ auto T = gameMatrix::translate(pos);
+
+ assert(T[0][3] == 3);
+ assert(T[1][3] == -2);
+ assert(T[2][3] == 8);
+}
+
+void test_rot3D_basic() {
+ auto R = gameMatrix::rot3D(90, 'x');
+ // cos(90°) ≈ 0, sin(90°) ≈ 1
+ assert(std::abs(R[1][1]) < 1e-6);
+ assert(std::abs(R[1][2] + 1.0) < 1e-6);
+}
+
+int main() {
+ test_matmul_basic();
+ test_translate_basic();
+ test_rot3D_basic();
+
+ std::cout << "Test bestanden!\n";
+ return 0;
+}
diff --git a/tests.exe b/tests.exe
deleted file mode 100644
index c4774be..0000000
Binary files a/tests.exe and /dev/null differ