Files
j3ml/include/J3ML/Rotation.hpp
josh c7919a0928
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 23s
Build Docs With Doxygen / Explore-Gitea-Actions (push) Successful in 28s
Yee
2025-06-27 20:49:30 -05:00

57 lines
1.8 KiB
C++

#pragma once
#include "J3ML.hpp"
#include "LinearAlgebra/Vector2.hpp"
namespace J3ML::Math {
/// Rotation is a class that represents a single axis of rotation.
/// The class is designed to behave very similarly to a float literal, and
/// primarily help organize code involving rotations by handling common boilerplate
/// and providing mathematical expressions.
struct Rotation {
constexpr Rotation();
constexpr Rotation(float value);
constexpr explicit Rotation(const Vector2& direction_vector);
constexpr Rotation FromDegrees(float degrees);
constexpr Rotation FromRadians(float radians);
//Rotation(const Types::Radians& radians);
//Rotation(const Types::Degrees& degrees);
constexpr float Radians() const { return value;}
//Types::Radians Radians() const { return {value}; }
constexpr float Degrees() const { return Math::Degrees(value); }
constexpr Rotation operator+(const Rotation& rhs) const;
constexpr Rotation operator-(const Rotation& rhs) const;
constexpr Rotation operator*(float scalar) const;
constexpr Rotation operator/(float scalar) const;
constexpr bool operator==(const Rotation& rhs) const = default;
constexpr Rotation operator-() const;
/// Rotates a given Vector2 by this Rotation.
Vector2 Rotate(const Vector2& rhs) const;
float operator()() const { return value; }
Rotation& operator=(const Rotation& rhs) {
this->value = rhs.value;
return *this;
}
protected:
float value;
};
constexpr Rotation operator ""_rad(long double rads);
constexpr Rotation operator ""_radians(long double rads);
constexpr Rotation operator ""_deg(long double rads);
constexpr Rotation operator ""_degrees(long double rads);
}