diff options
| author | Mel <einebeere@gmail.com> | 2023-08-06 04:27:07 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-08-06 04:27:07 +0200 |
| commit | 5a1b126f1f6d55226c2b5068d0c17c428fd29ba8 (patch) | |
| tree | 3acc0240cd8dedd0764eeae6df04e134b04584c8 /src/Math/Rotation.hpp | |
| parent | e6f5f9e03f673db796f1babb308609ca2576db2f (diff) | |
| download | meowcraft-5a1b126f1f6d55226c2b5068d0c17c428fd29ba8.tar.zst meowcraft-5a1b126f1f6d55226c2b5068d0c17c428fd29ba8.zip | |
Create separate Player entity and add bad collision system
Diffstat (limited to 'src/Math/Rotation.hpp')
| -rw-r--r-- | src/Math/Rotation.hpp | 25 |
1 files changed, 16 insertions, 9 deletions
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 <cmath> +#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 |
