13 #include <type_traits> 37 template <
class T1,
class ... Tn>
38 struct ArithmeticChecker<T1, Tn...> : std::conjunction<std::conjunction<ArithmeticChecker<Tn...>>, std::is_arithmetic<T1>> {
48 template <
class ... Tn>
54 template <
class ... Tn>
57 static constexpr
long double EPSILON = 0.000001;
58 static constexpr
long double PI = 3.141592653589793238462643383279502884L;
66 template <
class T,
class K,
typename std::enable_if_t< std::is_
floating_po
int<std::common_type_t<T, K>>::value,
int> = 0>
67 constexpr
bool equal(T a, K b) {
68 return std::abs(static_cast <std::common_type_t<T, K>> (a) - static_cast <std::common_type_t<T, K>> (b)) < EPSILON;
77 template <
class T,
class K,
typename std::enable_if_t<!std::is_
floating_po
int<std::common_type_t<T, K>>::value,
int> = 0>
78 constexpr
bool equal(T a, K b) {
79 return static_cast <std::common_type_t<T, K>> (a) == static_cast <std::common_type_t<T, K>> (b);
87 template <
class T,
class K>
98 template <
class T,
typename = UseIfArithmetic<T>>
99 constexpr T
lerp(T
const& a, T
const& b,
float const& f) {
100 return a * (1.0f - f) + b * f;
std::enable_if_t< ArithmeticCheckerV< Tn... >> UseIfArithmetic
Definition: NRE_Math.hpp:55
constexpr bool equal(T a, K b)
Definition: NRE_Math.hpp:67
constexpr bool ArithmeticCheckerV
Definition: NRE_Math.hpp:49
Template structure allowing compile-time check on template parameters if they are arithmetic or not...
Definition: NRE_Math.hpp:31
The NearlyRealEngine's global namespace.
constexpr T lerp(T const &a, T const &b, float const &f)
Definition: NRE_Math.hpp:99
constexpr bool almostEqual(T a, K b)
Definition: NRE_Math.hpp:88