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 Pi3 = Pi / 3;
66 constexpr
float Pi4 = Pi / 4;
72 constexpr
float Pi6 = Pi / 6;
78 constexpr
float Sqrt2 = 1.41421356237309504880f;
90 constexpr
float Sqrt3 = 1.7320508075688772935f;
96 constexpr
float Epsilon = std::numeric_limits<float>::epsilon();
115 T diff = std::abs(a - b);
117 if (a == 0 || b == 0 || diff < std::numeric_limits<T>::denorm_min()) {
118 return diff < (epsilon * std::numeric_limits<T>::denorm_min());
121 T sum = std::abs(a) + std::abs(b);
122 sum = (sum < std::numeric_limits<T>::max()) ? sum : std::numeric_limits<T>::max();
124 return (diff / sum) < epsilon;
138 return degrees * gf::pi<T>() /
T(180);
152 return radians *
T(180) / gf::pi<T>();
213 return (-
T(2) * t +
T(3)) * t * t;
236 return ((
T(6) * t -
T(15)) * t +
T(10)) * t * t * t;
250 return (
T(1) - std::cos(gf::pi<T>() * t)) *
T(0.5);
266 template<
typename T,
typename U>
269 return (
U(1) - t) * lhs + t * rhs;
287 return val < lo ? lo : (val > hi ? hi : val);
317 return val * val * val;
337 return (val >
T(0)) - (val <
T(0));
355 return lhs > rhs ? lhs - rhs : rhs - lhs;
358 #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:268
constexpr float Epsilon
Machine epsilon.
Definition: Math.h:96
constexpr T cube(T val)
Cube function.
Definition: Math.h:316
constexpr float Pi6
The constant.
Definition: Math.h:72
constexpr float InvSqrt2
The constant.
Definition: Math.h:84
constexpr T absdiff(T lhs, T rhs)
Absolute difference of two values.
Definition: Math.h:354
constexpr T square(T val)
Square function.
Definition: Math.h:301
constexpr T clamp(T val, T lo, T hi)
Clamping function.
Definition: Math.h:286
constexpr float Sqrt2
The constant.
Definition: Math.h:78
constexpr T radiansToDegrees(T radians)
Convert radians to degrees.
Definition: Math.h:151
constexpr T cubicStep(T t)
Cubic step (smoothstep)
Definition: Math.h:212
The namespace for gf classes.
Definition: Action.h:35
T cosineStep(T t)
Cosine step.
Definition: Math.h:249
constexpr T degreesToRadians(T degrees)
Convert degrees to radians.
Definition: Math.h:137
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:110
constexpr T linearStep(T t)
Linear step.
Definition: Math.h:191
constexpr float Sqrt3
The constant.
Definition: Math.h:90
constexpr int sign(T val)
Sign function.
Definition: Math.h:336
constexpr float Pi3
The constant.
Definition: Math.h:60
T(*)(T) Step
A step is a function with special features.
Definition: Math.h:179
constexpr T quinticStep(T t)
Quintic step (smootherstep)
Definition: Math.h:235
constexpr T pi()
Templated value of .
Definition: Math.h:40
constexpr float Pi4
The constant.
Definition: Math.h:66