summary refs log tree commit diff
path: root/src/Math/Rotation.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-10-04 01:18:19 +0200
committerMel <einebeere@gmail.com>2022-10-04 01:18:19 +0200
commit0631fb666d2a28a6eb9b8d1578675699b41a5de6 (patch)
tree1db9b88d9c11074864f6959d32960eb6c54d3c4b /src/Math/Rotation.hpp
parent75f3941579c756655fc7d4d29e7b92b6eae436b7 (diff)
downloadmeowcraft-0631fb666d2a28a6eb9b8d1578675699b41a5de6.tar.zst
meowcraft-0631fb666d2a28a6eb9b8d1578675699b41a5de6.zip
Cube Rendering
Diffstat (limited to 'src/Math/Rotation.hpp')
-rw-r--r--src/Math/Rotation.hpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Math/Rotation.hpp b/src/Math/Rotation.hpp
new file mode 100644
index 0000000..334ede2
--- /dev/null
+++ b/src/Math/Rotation.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <cmath>
+#include "Vector.hpp"
+
+struct Rotation {
+public:
+    Rotation() : vector{} {};
+
+    Rotation(Vector<3> vector) : vector{ wrap(vector) } {};
+
+    Rotation(float angles[3]) : Rotation(angles[0], angles[1], angles[2]) {};
+
+    Rotation(float x, float y, float z) {
+        vector = wrap({ x, y, z });
+    };
+
+    Rotation operator+(Rotation other) const {
+        return wrap(vector + other.vector);
+    }
+
+    std::string string() const {
+        return vector.string();
+    }
+
+    static Vector<3> wrap(Vector<3> v) {
+        return v.apply([=](float a) -> float { return fmod(a, 360.0f); });
+    }
+
+    Vector<3> vector;
+};
\ No newline at end of file