aboutsummaryrefslogtreecommitdiff
path: root/src/engine/matrix.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/matrix.hpp')
-rw-r--r--src/engine/matrix.hpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/engine/matrix.hpp b/src/engine/matrix.hpp
new file mode 100644
index 0000000..ddc1a1c
--- /dev/null
+++ b/src/engine/matrix.hpp
@@ -0,0 +1,64 @@
+#pragma once
+
+#include "vector2.hpp"
+#include <vector>
+
+/**
+ * A Matrix.
+ */
+template <typename Element>
+class Matrix
+{
+public:
+ /**
+ * Creates a matrix.
+ *
+ * @param rows The number of rows of the matrix
+ * @param columns The number of columns of the matrix
+ */
+ Matrix(unsigned int rows, unsigned int columns);
+
+ /**
+ * Fills the matrix with a element.
+ *
+ * @param element A element
+ */
+ void fill(Element element);
+
+ /**
+ * Prints the matrix.
+ */
+ void print();
+
+ /**
+ * Returns a element of the matrix.
+ *
+ * @param pos The position of a element
+ */
+ Element get(Vector2 pos);
+
+ /**
+ * Sets a element of the matrix.
+ *
+ * @param pos The position of a element
+ * @param element A new element
+ */
+ void set(Vector2 pos, Element element);
+
+ /**
+ * Returns the number of rows the matrix has.
+ */
+ unsigned int rows();
+
+ /**
+ * Returns the number of columns the matrix has.
+ */
+ unsigned int columns();
+
+private:
+ std::vector<std::vector<Element>> _matrix;
+ unsigned int _rows;
+ unsigned int _columns;
+};
+
+#include "matrix.tpp"