From 5a1b126f1f6d55226c2b5068d0c17c428fd29ba8 Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 6 Aug 2023 04:27:07 +0200 Subject: Create separate Player entity and add bad collision system --- src/Math/Rotation.hpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/Math/Rotation.hpp') diff --git a/src/Math/Rotation.hpp b/src/Math/Rotation.hpp index 83c1109..d5bc023 100644 --- a/src/Math/Rotation.hpp +++ b/src/Math/Rotation.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include "Trig.hpp" #include "Vector.hpp" struct Rotation { @@ -14,10 +15,19 @@ struct Rotation { vector = wrap({pitch, yaw, roll }); } + Vector<3> radians() const { + return vector.map([](auto a) { return Math::radians(a); }); + } + Rotation operator+(Rotation other) const { return wrap(vector + other.vector); } + Rotation& operator+=(const Rotation& other) { + *this = *this + other; + return *this; + } + std::string string() const { return vector.string(); } @@ -26,17 +36,14 @@ struct Rotation { return v.map([](auto a) { return fmod(a, 360.0f); }); } - Real& pitch() { - return vector[0]; - } + Real& pitch() { return vector.x(); } + const Real& pitch() const { return vector.x(); } - Real& yaw() { - return vector[1]; - } + Real& yaw() { return vector.y(); } + const Real& yaw() const { return vector.y(); } - Real& roll() { - return vector[2]; - } + Real& roll() { return vector.z(); } + const Real& roll() const { return vector.z(); } Vector<3> vector; }; \ No newline at end of file -- cgit 1.4.1