From 0631fb666d2a28a6eb9b8d1578675699b41a5de6 Mon Sep 17 00:00:00 2001 From: Mel Date: Tue, 4 Oct 2022 01:18:19 +0200 Subject: Cube Rendering --- src/Math/Rotation.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/Math/Rotation.hpp (limited to 'src/Math/Rotation.hpp') 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 +#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 -- cgit 1.4.1