27 #include "Portability.h" 30 #ifndef DOXYGEN_SHOULD_SKIP_THIS 41 return T(3.141592653589793238462643383279502884197169399
L);
48 constexpr
float Pi = pi<float>();
54 constexpr
float Pi2 = Pi / 2;
60 constexpr
float Pi4 = Pi / 4;
66 constexpr
float Sqrt2 = 1.41421356237309504880f;
78 constexpr
float Sqrt3 = 1.7320508075688772935f;
84 constexpr
float Epsilon = std::numeric_limits<float>::epsilon();
103 T diff = std::abs(a - b);
105 if (a == 0 || b == 0 || diff < std::numeric_limits<T>::denorm_min()) {
106 return diff < (epsilon * std::numeric_limits<T>::denorm_min());
109 T sum = std::abs(a) + std::abs(b);
110 sum = (sum < std::numeric_limits<T>::max()) ? sum : std::numeric_limits<T>::max();
112 return (diff / sum) < epsilon;
126 return degrees * gf::pi<T>() /
T(180);
140 return radians *
T(180) / gf::pi<T>();
201 return (-
T(2) * t +
T(3)) * t * t;
224 return ((
T(6) * t -
T(15)) * t +
T(10)) * t * t * t;
238 return (
T(1) - std::cos(gf::pi<T>() * t)) *
T(0.5);
254 template<
typename T,
typename U>
257 return (
U(1) - t) * lhs + t * rhs;
275 return val < lo ? lo : (val > hi ? hi : val);
305 return val * val * val;
325 return (val >
T(0)) - (val <
T(0));
343 return lhs > rhs ? lhs - rhs : rhs - lhs;
346 #ifndef DOXYGEN_SHOULD_SKIP_THIS constexpr float Pi2
The constant.
Definition: Math.h:54
constexpr T lerp(T lhs, T rhs, U t)
Linear interpolation function.
Definition: Math.h:256
constexpr float Epsilon
Machine epsilon.
Definition: Math.h:84
constexpr T cube(T val)
Cube function.
Definition: Math.h:304
constexpr float InvSqrt2
The constant.
Definition: Math.h:72
constexpr T absdiff(T lhs, T rhs)
Absolute difference of two values.
Definition: Math.h:342
constexpr T square(T val)
Square function.
Definition: Math.h:289
constexpr T clamp(T val, T lo, T hi)
Clamping function.
Definition: Math.h:274
constexpr float Sqrt2
The constant.
Definition: Math.h:66
constexpr T radiansToDegrees(T radians)
Convert radians to degrees.
Definition: Math.h:139
constexpr T cubicStep(T t)
Cubic step (smoothstep)
Definition: Math.h:200
The namespace for gf classes.
Definition: Action.h:35
T cosineStep(T t)
Cosine step.
Definition: Math.h:237
constexpr T degreesToRadians(T degrees)
Convert degrees to radians.
Definition: Math.h:125
constexpr float Pi
The constant.
Definition: Math.h:48
constexpr bool almostEquals(T a, T b, T epsilon=std::numeric_limits< T >::epsilon())
Compare two floats.
Definition: Math.h:98
constexpr T linearStep(T t)
Linear step.
Definition: Math.h:179
constexpr float Sqrt3
The constant.
Definition: Math.h:78
constexpr int sign(T val)
Sign function.
Definition: Math.h:324
T(*)(T) Step
A step is a function with special features.
Definition: Math.h:167
constexpr T quinticStep(T t)
Quintic step (smootherstep)
Definition: Math.h:223
constexpr T pi()
Templated value of .
Definition: Math.h:40
constexpr float Pi4
The constant.
Definition: Math.h:60