22 #define _USE_MATH_DEFINES 26 #define M_PI 3.14159265358979323846 27 #define M_PI_2 1.57079632679489661923 28 #define M_PI_4 0.785398163397448309616 31 inline bool AreSame(
const float l,
const float r) {
32 return std::fabs(l-r) <= FLT_EPSILON;
35 inline bool AreSame(
const double l,
const double r) {
36 return std::fabs(l-r) <= DBL_EPSILON;
40 inline _Tx Round(
const _Tx& x)
42 return x < static_cast<_Tx>(0) ? std::ceil(x - static_cast<_Tx>(0.5)) : std::floor(x + static_cast<_Tx>(0.5));
46 inline _Tx Sqr(
const _Tx& x)
52 inline _Tx Sign(
const _Tx& x)
54 return (_Tx(0) < x) - (x < _Tx(0));
58 inline _Tx Clamp(
const _Tx& x,
const _Tx& min,
const _Tx& max)
60 return std::min(std::max(x, min), max);