21 #include "hx3d/math/number_utils.hpp" 28 float clamp(
float value,
float min,
float max) {
29 if (value < min)
return min;
30 if (value > max)
return max;
34 float mclamp(
float value,
float min,
float max) {
35 if (value < min)
return max -
modulo(value, min);
36 if (value >= max)
return min +
modulo(value, max);
45 return a >= 0 ? a % b : (b -
static_cast<unsigned int>(std::abs((
float)(a % b)))) % b;
49 return (std::log(a) / std::log(2));
float mclamp(float value, float min, float max)
Modulo clamp.
float log2(int a)
Calculate the log2.
float clamp(float value, float min, float max)
Simple clamp.
int modulo(int a, int b)
Modulo. Handles negative values !