28#ifndef DOXYGEN_SHOULD_SKIP_THIS
39 return T(3.141592653589793238462643383279502884197169399L);
46 constexpr float Pi = pi<float>();
76 constexpr float Sqrt2 = 1.41421356237309504880f;
88 constexpr float Sqrt3 = 1.7320508075688772935f;
94 constexpr float Epsilon = std::numeric_limits<float>::epsilon();
108 bool almostEquals(T a, T b, T epsilon = std::numeric_limits<T>::epsilon()) {
113 T diff = std::abs(a - b);
115 if (a == 0 || b == 0 || diff < std::numeric_limits<T>::denorm_min()) {
116 return diff < (epsilon * std::numeric_limits<T>::denorm_min());
119 T sum = std::abs(a) + std::abs(b);
120 sum = (sum < std::numeric_limits<T>::max()) ? sum : std::numeric_limits<T>::max();
122 return (diff / sum) < epsilon;
136 return degrees * gf::pi<T>() /
T(180);
150 return radians *
T(180) / gf::pi<T>();
211 return (-
T(2) * t +
T(3)) * t * t;
234 return ((
T(6) * t -
T(15)) * t +
T(10)) * t * t * t;
248 return (
T(1) - std::cos(gf::pi<T>() * t)) *
T(0.5);
264 template<
typename T,
typename U>
267 return T((
U(1) - t) * lhs + t * rhs);
285 return val < lo ? lo : (val > hi ? hi : val);
315 return val * val * val;
335 return (val >
T(0)) - (val <
T(0));
353 return lhs > rhs ? lhs - rhs : rhs - lhs;
356#ifndef DOXYGEN_SHOULD_SKIP_THIS
constexpr float Pi3
The constant.
Definition: Math.h:58
constexpr T square(T val)
Square function.
Definition: Math.h:299
T cosineStep(T t)
Cosine step.
Definition: Math.h:247
constexpr T absdiff(T lhs, T rhs)
Absolute difference of two values.
Definition: Math.h:352
constexpr T degreesToRadians(T degrees)
Convert degrees to radians.
Definition: Math.h:135
constexpr T radiansToDegrees(T radians)
Convert radians to degrees.
Definition: Math.h:149
T(*)(T) Step
A step is a function with special features.
Definition: Math.h:177
constexpr int sign(T val)
Sign function.
Definition: Math.h:334
constexpr T clamp(T val, T lo, T hi)
Clamping function.
Definition: Math.h:284
constexpr T quinticStep(T t)
Quintic step (smootherstep)
Definition: Math.h:233
constexpr T cube(T val)
Cube function.
Definition: Math.h:314
constexpr float Sqrt2
The constant.
Definition: Math.h:76
constexpr bool almostEquals(T a, T b, T epsilon=std::numeric_limits< T >::epsilon())
Compare two floats.
Definition: Math.h:108
constexpr T lerp(T lhs, T rhs, U t)
Linear interpolation function.
Definition: Math.h:266
constexpr float Pi4
The constant.
Definition: Math.h:64
constexpr float Pi2
The constant.
Definition: Math.h:52
constexpr float Pi6
The constant.
Definition: Math.h:70
constexpr T cubicStep(T t)
Cubic step (smoothstep)
Definition: Math.h:210
constexpr float Epsilon
Machine epsilon.
Definition: Math.h:94
constexpr T pi()
Templated value of .
Definition: Math.h:38
constexpr float InvSqrt2
The constant.
Definition: Math.h:82
constexpr float Sqrt3
The constant.
Definition: Math.h:88
constexpr T linearStep(T t)
Linear step.
Definition: Math.h:189
constexpr float Pi
The constant.
Definition: Math.h:46
The namespace for gf classes.