OGLplus  (0.59.0) a C++ wrapper for rendering APIs

quantities.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_QUANTITIES_HPP
10 #define EAGINE_QUANTITIES_HPP
11 
12 #include "diagnostic.hpp"
13 #include "math/constants.hpp"
14 #include "tagged_quantity.hpp"
15 #include "units/common.hpp"
16 
17 #ifdef __clang__
18 EAGINE_DIAG_PUSH()
19 EAGINE_DIAG_OFF(double-promotion)
20 #endif
21 
22 namespace eagine {
23 
27 template <typename T>
29 
32 template <typename T>
33 static constexpr auto seconds_(T value) noexcept -> seconds_t<T> {
34  return seconds_t<T>{value};
35 }
36 
40 template <typename T>
42 
49 template <typename T>
50 static constexpr auto radians_(T value) noexcept -> radians_t<T> {
51  return radians_t<T>{value};
52 }
53 
60 template <typename T>
61 static constexpr auto right_angles_(T value) noexcept {
62  return radians_(value * math::pi / 2);
63 }
64 
71 static constexpr auto right_angle_() noexcept {
72  return right_angles_(1);
73 }
74 
81 template <typename T>
82 static constexpr auto turns_(T value) noexcept {
83  return radians_(value * math::pi * 2);
84 }
85 
93 template <
94  typename Qty,
95  typename = std::enable_if_t<is_convertible_quantity_v<Qty, units::radian>>>
96 static constexpr auto sin(const Qty& qty) {
97  using std::sin;
98  return sin(value(convert_to<units::radian>(qty)));
99 }
100 
108 template <
109  typename Qty,
110  typename = std::enable_if_t<is_convertible_quantity_v<Qty, units::radian>>>
111 static constexpr auto cos(const Qty& qty) {
112  using std::cos;
113  return cos(value(convert_to<units::radian>(qty)));
114 }
115 
123 template <
124  typename Qty,
125  typename = std::enable_if_t<is_convertible_quantity_v<Qty, units::radian>>>
126 static constexpr auto tan(const Qty& qty) {
127  using std::tan;
128  return tan(value(convert_to<units::radian>(qty)));
129 }
130 
138 template <typename T>
139 static constexpr auto arcsin(T x) {
140  using std::asin;
141  return make_tagged_quantity<units::radian>(asin(x));
142 }
143 
151 template <typename T>
152 static constexpr auto arccos(T x) {
153  using std::acos;
154  return make_tagged_quantity<units::radian>(acos(x));
155 }
156 
164 template <typename T>
165 static constexpr auto arctan(T y, T x) {
166  using std::atan2;
167  return make_tagged_quantity<units::radian>(atan2(y, x));
168 }
169 
173 template <typename T>
175 
182 template <typename T>
183 static constexpr auto degrees_(T value) noexcept -> degrees_t<T> {
184  return degrees_t<T>{value};
185 }
186 
190 template <typename T>
192 
195 template <typename T>
196 static constexpr auto kelvins_(T value) noexcept -> kelvins_t<T> {
197  return kelvins_t<T>{value};
198 }
199 
200 } // namespace eagine
201 
202 #ifdef __clang__
203 EAGINE_DIAG_POP()
204 #endif
205 
206 #endif // EAGINE_QUANTITIES_HPP
static constexpr auto sin(const Qty &qty)
Overload of sine for quantities of angle.
Definition: quantities.hpp:96
Common code is placed in this namespace.
Definition: eagine.hpp:21
static constexpr auto kelvins_(T value) noexcept -> kelvins_t< T >
Creates a tagged quantity storing value in kelvins.
Definition: quantities.hpp:196
static constexpr auto arctan(T y, T x)
Overload of tangens for quantities of angle.
Definition: quantities.hpp:165
static constexpr auto tan(const Qty &qty)
Overload of tangens for quantities of angle.
Definition: quantities.hpp:126
static constexpr const auto pi
The pi constant.
Definition: constants.hpp:23
static constexpr auto seconds_(T value) noexcept -> seconds_t< T >
Creates a tagged quantity storing value in seconds.
Definition: quantities.hpp:33
static constexpr auto radians_(T value) noexcept -> radians_t< T >
Creates a tagged quantity storing value in radians.
Definition: quantities.hpp:50
static constexpr auto turns_(T value) noexcept
Creates a tagged quantity in full turn units.
Definition: quantities.hpp:82
static constexpr auto arccos(T x)
Overload of arc cosine for quantities of angle.
Definition: quantities.hpp:152
static constexpr auto right_angles_(T value) noexcept
Creates a tagged quantity in units of right angle.
Definition: quantities.hpp:61
static constexpr auto degrees_(T value) noexcept -> degrees_t< T >
Creates a tagged quantity storing value in degrees.
Definition: quantities.hpp:183
static constexpr auto arcsin(T x)
Overload of arc sine for quantities of angle.
Definition: quantities.hpp:139
static constexpr auto cos(const Qty &qty)
Overload of cosine for quantities of angle.
Definition: quantities.hpp:111
Value of type T with a specified unit or tag type U.
Definition: tagged_quantity.hpp:27
static constexpr auto right_angle_() noexcept
Creates a tagged quantity a right angle value.
Definition: quantities.hpp:71

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).