Plasma Engine  2.0
Loading...
Searching...
No Matches
Angle.h
1#pragma once
2
3#include <Foundation/Math/Declarations.h>
4
9class PL_FOUNDATION_DLL plAngle
10{
11public:
12 PL_DECLARE_POD_TYPE();
13
15 template <typename Type>
16 constexpr static PL_ALWAYS_INLINE Type DegToRadMultiplier(); // [tested]
17
19 template <typename Type>
20 constexpr static PL_ALWAYS_INLINE Type RadToDegMultiplier(); // [tested]
21
23 template <typename Type>
24 constexpr static Type DegToRad(Type f); // [tested]
25
27 template <typename Type>
28 constexpr static Type RadToDeg(Type f); // [tested]
29
31 [[nodiscard]] constexpr static plAngle MakeZero() { return plAngle(); }
32
34 [[nodiscard]] constexpr static plAngle MakeFromDegree(float fDegree); // [tested]
35
37 [[nodiscard]] constexpr static plAngle MakeFromRadian(float fRadian); // [tested]
38
40 constexpr plAngle()
41 : m_fRadian(0.0f)
42 {
43 } // [tested]
44
46 constexpr float GetDegree() const; // [tested]
47
49 constexpr float GetRadian() const; // [tested]
50
52 PL_ALWAYS_INLINE void SetRadian(float fRad) { m_fRadian = fRad; };
53
56 void NormalizeRange(); // [tested]
57
60 plAngle GetNormalizedRange() const; // [tested]
61
65 constexpr static plAngle AngleBetween(plAngle a, plAngle b); // [tested]
66
68 bool IsEqualSimple(plAngle rhs, plAngle epsilon) const; // [tested]
69
71 bool IsEqualNormalized(plAngle rhs, plAngle epsilon) const; // [tested]
72
73 // unary operators
74 constexpr plAngle operator-() const; // [tested]
75
76 // arithmetic operators
77 constexpr plAngle operator+(plAngle r) const; // [tested]
78 constexpr plAngle operator-(plAngle r) const; // [tested]
79
80 // compound assignment operators
81 void operator+=(plAngle r); // [tested]
82 void operator-=(plAngle r); // [tested]
83
84 // comparison
85 constexpr bool operator==(const plAngle& r) const; // [tested]
86 constexpr bool operator!=(const plAngle& r) const; // [tested]
87
88 // At least the < operator is implement to make clamping etc. work
89 constexpr bool operator<(const plAngle& r) const;
90 constexpr bool operator>(const plAngle& r) const;
91 constexpr bool operator<=(const plAngle& r) const;
92 constexpr bool operator>=(const plAngle& r) const;
93
94 // Note: relational operators on angles are not really possible - is 0 degree smaller or bigger than 359 degree?
95
96private:
98 constexpr explicit plAngle(float fRadian)
99 : m_fRadian(fRadian)
100 {
101 }
102
104 float m_fRadian;
105
107 template <typename Type>
108 constexpr static Type Pi();
109};
110
111// Mathematical operators with float
112
114constexpr plAngle operator*(plAngle a, float f); // [tested]
116constexpr plAngle operator*(float f, plAngle a); // [tested]
117
119constexpr plAngle operator/(plAngle a, float f); // [tested]
121constexpr float operator/(plAngle a, plAngle b); // [tested]
122
123#include <Foundation/Math/Implementation/Angle_inl.h>
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
constexpr plAngle()
Standard constructor, initializing with 0.
Definition Angle.h:40
PL_ALWAYS_INLINE void SetRadian(float fRad)
Sets the radian value. (No need for any conversion)
Definition Angle.h:52
static constexpr plAngle MakeZero()
Returns a zero initialized angle. Same as a default constructed object.
Definition Angle.h:31
constexpr TYPE Pi()
Returns the natural constant Pi.