NRE_Math.hpp File Reference

Implementation of Math's API's function. More...

#include <cmath>
#include <type_traits>

Go to the source code of this file.

Classes

class  NRE::Math::ArithmeticChecker<... >
 Template structure allowing compile-time check on template parameters if they are arithmetic or not. More...
 
struct  NRE::Math::ArithmeticChecker< T1, Tn... >
 
struct  NRE::Math::ArithmeticChecker< T1 >
 

Namespaces

 NRE
 The NearlyRealEngine's global namespace.
 
 Math
 Math's API.
 

Typedefs

template<class... Tn>
using NRE::Math::UseIfArithmetic = std::enable_if_t< ArithmeticCheckerV< Tn... >>
 

Functions

template<class T , class K , typename std::enable_if_t< std::is_floating_point< std::common_type_t< T, K >>::value, int > = 0>
constexpr bool NRE::Math::equal (T a, K b)
 
template<class T , class K >
constexpr bool NRE::Math::almostEqual (T a, K b)
 
template<class T , typename = UseIfArithmetic<T>>
constexpr T NRE::Math::lerp (T const &a, T const &b, float const &f)
 

Variables

template<class... Tn>
constexpr bool NRE::Math::ArithmeticCheckerV = ArithmeticChecker<Tn...>::value
 

Detailed Description

Implementation of Math's API's function.

Author
Louis ABEL
Date
03/04/2019

Typedef Documentation

template<class... Tn>
using NRE::Math::UseIfArithmetic = typedef std::enable_if_t<ArithmeticCheckerV<Tn...>>

Enable a function if all given template parameters are arithmetics types

Function Documentation

template<class T , class K >
constexpr bool NRE::Math::almostEqual ( a,
b 
)

Test if 2 objects are almost equals (usefull for floating point objects)

Parameters
athe first object
bthe second object
Returns
if both objets are almost equals
template<class T , class K , typename std::enable_if_t< std::is_floating_point< std::common_type_t< T, K >>::value, int > = 0>
constexpr bool NRE::Math::equal ( a,
b 
)

Test the equality of 2 objects

Parameters
athe first object
bthe second object
Returns
if both objets are equals
template<class T , typename = UseIfArithmetic<T>>
constexpr T NRE::Math::lerp ( T const &  a,
T const &  b,
float const &  f 
)

Perform a linear interpolation

Parameters
athe first value to interpolate
bthe second value to interpolate
fthe scale factor
Returns
the interpolated value

Variable Documentation

template<class... Tn>
constexpr bool NRE::Math::ArithmeticCheckerV = ArithmeticChecker<Tn...>::value

Shortcut to use ArithmeticChecker internal value