Control Surface main
MIDI Control Surface library for Arduino
Degrees.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <AH/STL/type_traits>
10AH_DIAGNOSTIC_WERROR() // Enable errors on warnings
11
13
14namespace detail {
15constexpr long double pi_inv_l = 0.318309886183790671537767526745028724L;
16constexpr long double pi_l = 3.141592653589793238462643383279502884L;
17} // namespace detail
18
21
23template <class T>
24constexpr inline
25 typename std::enable_if<std::is_floating_point<T>::value, T>::type
26 rad2deg(T r) {
27 return r * static_cast<T>(detail::pi_inv_l) * 180;
28}
30template <class T>
31constexpr inline
32 typename std::enable_if<std::is_floating_point<T>::value, T>::type
33 deg2rad(T d) {
34 return d * static_cast<T>(detail::pi_l) / 180;
35}
36
38constexpr long double operator"" _deg(long double deg) { return deg2rad(deg); }
40constexpr long double operator"" _deg(unsigned long long deg) {
41 return deg2rad(static_cast<long double>(deg));
42}
43
45
47
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:37
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:36
constexpr std::enable_if< std::is_floating_point< T >::value, T >::type rad2deg(T r)
Convert radians to degrees.
Definition: Degrees.hpp:26
constexpr std::enable_if< std::is_floating_point< T >::value, T >::type deg2rad(T d)
Convert degrees to radians.
Definition: Degrees.hpp:33
constexpr long double pi_l
Definition: Degrees.hpp:16
constexpr long double pi_inv_l
Definition: Degrees.hpp:15