SA_Maths
Sapphire Suite's C++ Maths Library
Loading...
Searching...
No Matches
Radian.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 Sapphire development team. All Rights Reserved.
2
3#pragma once
4
5#ifndef SAPPHIRE_MATHS_RADIAN_GUARD
6#define SAPPHIRE_MATHS_RADIAN_GUARD
7
8#include <cmath>
9
10#include <SA/Maths/Debug.hpp>
11
14
24namespace SA
25{
26 template <typename T>
27 class Deg;
28
34 template <typename T>
35 class Rad
36 {
38 T mHandle = T(0.0);
39
40 public:
42 Rad() = default;
43
49 constexpr Rad(T _rad) noexcept;
50
56 template <typename TIn>
57 constexpr Rad(Rad<TIn> _other) noexcept;
58
64 template <typename TIn>
65 constexpr Rad(Deg<TIn> _deg) noexcept;
66
67
73 constexpr T Handle() const noexcept;
74
83 constexpr bool Equals(Rad _other, T _epsilon = std::numeric_limits<T>::epsilon()) const noexcept;
84
85
89 void Clamp() noexcept;
90
91
97 constexpr Rad operator-() const noexcept;
98
106 constexpr Rad operator+(Rad _rhs) const noexcept;
107
115 constexpr Rad operator-(Rad _rhs) const noexcept;
116
124 constexpr Rad operator*(T _scale) const noexcept;
125
133 Rad operator/(T _scale) const;
134
135
143 Rad& operator+=(Rad _rhs) noexcept;
144
152 Rad& operator-=(Rad _rhs) noexcept;
153
161 Rad& operator*=(T _scale) noexcept;
162
170 Rad& operator/=(T _scale);
171
172
180 constexpr bool operator==(Rad _rhs) const noexcept;
181
189 constexpr bool operator!=(Rad _rhs) const noexcept;
190
191
197 explicit constexpr operator T() const noexcept;
198 };
199
200#if SA_LOGGER_IMPL
201
213 template <typename T>
214 std::string ToString(const Rad<T>& _r);
215
216#endif
217
218
219//{ Aliases
220
223
226
228 template <typename T>
229 using Radian = Rad<T>;
230
231//}
232
233
241 constexpr Radf operator""_rad(unsigned long long _lit) noexcept;
242
250 constexpr Radd operator""_rad(long double _lit) noexcept;
251}
252
261#include <SA/Maths/Angle/Radian.inl>
262
263#endif // GUARD
Maths Constants definition file.
Maths module Debug compatibility definition.
Equals method implementation.
Maths Degree type.
Definition Degree.hpp:37
Maths Radian type.
Definition Radian.hpp:36
constexpr bool Equals(Rad _other, T _epsilon=std::numeric_limits< T >::epsilon()) const noexcept
Compare 2 Rad.
void Clamp() noexcept
clamp this angle between [-Pi, Pi].
constexpr Rad(Deg< TIn > _deg) noexcept
Value constructor from radian.
constexpr Rad(T _rad) noexcept
Value constructor without conversion.
Rad()=default
Default contructor.
constexpr T Handle() const noexcept
Access the handled value.
constexpr Rad(Rad< TIn > _other) noexcept
Value constructor without conversion.