12inline constexpr static float PI = std::numbers::pi_v<float>;
22 constexpr Radian() =
default;
23 constexpr Radian(
float value) : value_(value){}
29 [[nodiscard]]
constexpr float value()
const {
return value_; }
31 constexpr Radian operator+(
Radian angle)
const {
return { value_ + angle.value() }; }
34 value_ += angle.value();
37 constexpr Radian operator-(
Radian angle)
const {
return { value_ - angle.value() }; }
40 value_ -= angle.value();
43 constexpr Radian operator*(
float value)
const {
return { value_ * value }; }
44 constexpr Radian operator/(
float value)
const {
return { value_ / value }; }
45 constexpr Radian operator-()
const {
return { -value_ }; }
58 constexpr Degree() =
default;
59 constexpr Degree(
float value) : value_(value){}
64 constexpr Degree(
const Radian& angle) : value_(angle.value()/PI*180.0f){}
65 [[nodiscard]]
constexpr float value()
const {
return value_; }
66 constexpr Degree operator+(Degree angle)
const {
return { value_ + angle.value() }; }
67 constexpr Degree& operator+=(Degree angle)
69 value_ += angle.value();
72 constexpr Degree operator-(Degree angle)
const {
return { value_ - angle.value() }; }
73 constexpr Degree& operator-=(Degree angle)
75 value_ -= angle.value();
78 constexpr Degree operator*(
float value)
const {
return { value_ * value }; }
79 constexpr Degree operator/(
float value)
const {
return { value_ / value }; }
80 constexpr Degree operator-()
const {
return { -value_ }; }
85constexpr Degree operator*(
float value, Degree angle) {
return angle.value() * value; }
88constexpr Radian::Radian(
const Degree& angle)
90 value_ = angle.value() / 180.0f * PI;
100 return std::sin(angle.value());
110 return std::cos(angle.value());
120 return std::tan(angle.value());
130 return {std::asin(ratio)};
140 return {std::acos(ratio)};
150 return {std::atan(ratio)};
161 return {std::atan2(y,x)};
Radian Acos(float ratio)
Acos is a function that calculates the angle of a given ratio.
Definition: angle.h:138
float Tan(Radian angle)
Tan is a function that calculates the tangent of a given angle.
Definition: angle.h:118
Radian Atan(float ratio)
Atan is a function that calculates the angle of a given ratio.
Definition: angle.h:148
float Sin(Radian angle)
Sin is a function that calculates the sinus of a given angle.
Definition: angle.h:98
Radian Asin(float ratio)
Asin is a function that calculates the angle of a given ratio.
Definition: angle.h:128
float Cos(Radian angle)
Cos is a function that calculates the cosinus of a given angle.
Definition: angle.h:108
Radian Atan2(float y, float x)
Atan2 is a function that calculates the angle of a given ratio between two parameters.
Definition: angle.h:159
Degree is an utility class that describes degree angles (0 to 360). It can be easily converted to Rad...
Definition: angle.h:56
constexpr Degree(const Radian &angle)
Conversion constructor that implicitly converts Radian to Degree.
Definition: angle.h:64
Radian is an utility class that describes radian angles (0 to 2PI). It can be easily converted to Deg...
Definition: angle.h:20