summary refs log tree commit diff
path: root/src/Math/Matrix.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-07-01 22:03:51 +0200
committerMel <einebeere@gmail.com>2023-07-01 22:03:51 +0200
commit221f632d6600ce03e09c2a44074ae100a507dd92 (patch)
tree462663c1f03582e8a0b5df753bc7c45cbe702aad /src/Math/Matrix.hpp
parent424d00eaf7335e1c6427f40260d55782c3fd902c (diff)
downloadmeowcraft-221f632d6600ce03e09c2a44074ae100a507dd92.tar.zst
meowcraft-221f632d6600ce03e09c2a44074ae100a507dd92.zip
Replace bespoke Generator maps with tensors and matrices
Diffstat (limited to 'src/Math/Matrix.hpp')
-rw-r--r--src/Math/Matrix.hpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/Math/Matrix.hpp b/src/Math/Matrix.hpp
index 276dc4a..69241d3 100644
--- a/src/Math/Matrix.hpp
+++ b/src/Math/Matrix.hpp
@@ -2,23 +2,21 @@
 
 #include <sstream>
 #include <cstddef>
-#include <iostream>
 #include "Rotation.hpp"
 #include "Trig.hpp"
 
 template <size_t R, size_t C, typename T = float>
 struct Matrix {
-public:
-    Matrix<R, C, T>() : elements{} {};
+    Matrix() : elements{} {};
 
-    Matrix<R, C, T>(T scalar) {
+    explicit Matrix(T scalar) {
         std::fill(elements, elements + R * C, scalar);
     };
 
-    template<typename ...Args, typename std::enable_if<sizeof...(Args) == R * C, int>::type = 0>
-    Matrix<R, C, T>(Args... args): elements{ args... } {};
+    template<typename ...Args, typename std::enable_if_t<sizeof...(Args) == R * C, int> = 0>
+    Matrix(Args... args): elements{ args... } {};
 
-    Matrix<R, C, T>(T values[R * C]) {
+    explicit Matrix(T values[R * C]) {
         std::copy(values, values + R * C, elements);
     };
 
@@ -81,8 +79,8 @@ public:
         return result;
     }
 
-    Matrix<R, C, T> transpose() {
-        Matrix<R, C, T> result{};
+    Matrix transpose() {
+        Matrix result{};
         for (int y = 0; y < R; y++) {
             for (int x = 0; x < C; x++) {
                 result(x, y) = this->operator()(y, x);
@@ -91,16 +89,16 @@ public:
         return result;
     }
 
-    Matrix<R, C, T> operator+(Matrix<R, C, T> other) {
-        Matrix<R, C, T> result{};
+    Matrix operator+(Matrix other) {
+        Matrix result{};
         for (int i = 0; i < R * C; i++) {
             result.elements[i] = elements[i] + other.elements[i];
         }
         return result;
     }
 
-    Matrix<R, C, T> operator*(float scalar) {
-        Matrix<R, C, T> result{};
+    Matrix operator*(float scalar) {
+        Matrix result{};
         for (int i = 0; i < R * C; i++) {
             result.elements[i] = elements[i] * scalar;
         }