diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 21:57:46 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 21:57:46 +1100 |
| commit | e4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch) | |
| tree | ed58c3c246e3af1af337697695d780aa31f6ad9a /src/shared/math/angles.hh | |
| parent | 1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff) | |
Update to most recent version (old initial commit)
Diffstat (limited to 'src/shared/math/angles.hh')
| -rw-r--r-- | src/shared/math/angles.hh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/shared/math/angles.hh b/src/shared/math/angles.hh new file mode 100644 index 0000000..aec388f --- /dev/null +++ b/src/shared/math/angles.hh @@ -0,0 +1,44 @@ +#ifndef SHARED_MATH_ANGLES_HH_ +#define SHARED_MATH_ANGLES_HH_ + +#include <algorithm> +#include <compare> + +#include <glm/glm.hpp> + +namespace shared { +namespace math { + +struct angles { +public: + float pitch; + float yaw; + +public: + // Returns the closest yaw from this to other, assumes they are normalised. + static float get_yaw_delta(const float& a, const float& b) noexcept; + +public: + glm::vec3 to_dir() const noexcept; + +public: + // Removes bad floating point values! + // Clamps pitch to its max positions of += glm::radians(89). + // Clamps yaw to its max positions of += glm::radians(180). + angles& clamp() noexcept; + + // Returns yaw angles to [glm::radians(-180), glm::radians(180)]. + angles& normalise() noexcept; + +public: + angles operator+(const angles& a) const noexcept; + angles operator*(const float& f) const noexcept; + +public: + auto operator<=>(const angles&) const noexcept = default; +}; + +} // namespace math +} // namespace shared + +#endif |
