SA_Maths
Sapphire Suite's C++ Maths Library
Loading...
Searching...
No Matches
Degree.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_DEGREE_GUARD
6#define SAPPHIRE_MATHS_DEGREE_GUARD
7
8#include <cmath>
9
10#include <SA/Maths/Debug.hpp>
11
14
25namespace SA
26{
27 template <typename T>
28 class Rad;
29
35 template <typename T>
36 class Deg
37 {
39 T mHandle = T(0);
40
41 public:
43 Deg() = default;
44
50 constexpr Deg(T _deg) noexcept;
51
57 template <typename TIn>
58 constexpr Deg(Deg<TIn> _other) noexcept;
59
65 template <typename TIn>
66 constexpr Deg(Rad<TIn> _rad) noexcept;
67
68
74 constexpr T Handle() const noexcept;
75
76
85 constexpr bool Equals(Deg _other, T _epsilon = std::numeric_limits<T>::epsilon()) const noexcept;
86
87
89 void Clamp() noexcept;
90
91
97 constexpr Deg operator-() const noexcept;
98
106 constexpr Deg operator+(Deg _rhs) const noexcept;
107
115 constexpr Deg operator-(Deg _rhs) const noexcept;
116
124 constexpr Deg operator*(T _scale) const noexcept;
125
133 Deg operator/(T _scale) const;
134
135
143 Deg& operator+=(Deg _rhs) noexcept;
144
152 Deg& operator-=(Deg _rhs) noexcept;
153
161 Deg& operator*=(T _scale) noexcept;
162
170 Deg& operator/=(T _scale);
171
172
180 constexpr bool operator==(Deg _rhs) const noexcept;
181
189 constexpr bool operator!=(Deg _rhs) const noexcept;
190
191
197 explicit constexpr operator T() const noexcept;
198 };
199
200
201#if SA_LOGGER_IMPL
202
214 template <typename T>
215 std::string ToString(const Deg<T>& _d);
216
217#endif
218
219
220//{ Aliases
221
224
227
229 template <typename T>
230 using Degree = Deg<T>;
231
232//}
233
241 constexpr Degf operator""_deg(unsigned long long _lit) noexcept;
242
250 constexpr Degd operator""_deg(long double _lit) noexcept;
251}
252
261#include <SA/Maths/Angle/Degree.inl>
262
263#endif // GUARD
Maths Constants definition file.
Maths module Debug compatibility definition.
Equals method implementation.
Maths Degree type.
Definition Degree.hpp:37
void Clamp() noexcept
clamp this angle between [-180, 180].
constexpr bool Equals(Deg _other, T _epsilon=std::numeric_limits< T >::epsilon()) const noexcept
Compare 2 Deg.
constexpr T Handle() const noexcept
Access the handled value.
constexpr Deg(T _deg) noexcept
Value constructor without conversion.
constexpr Deg(Deg< TIn > _other) noexcept
Value constructor without conversion.
constexpr Deg(Rad< TIn > _rad) noexcept
Value constructor from radian.
Deg()=default
Default contructor.
Maths Radian type.
Definition Radian.hpp:36