#ifndef MATH_H #define MATH_H #include #include #include uint32_t getDelta(uint32_t prev, uint32_t now); uint32_t getDelta(uint32_t prev, uint32_t now, uint32_t max); template T sign(T value) { if (value > 0) { return 1; } if (value < 0) { return -1; } return 0; } template T clamp(U value) { if (value >= std::numeric_limits().max()) { return std::numeric_limits().max(); } if (value <= std::numeric_limits().min()) { return std::numeric_limits().min(); } return value; } template T min(T x, T y) { if (x < y) { return x; } return y; } template T max(T x, T y) { if (x > y) { return x; } return y; } template T hypot(T x, T y) { return std::sqrt(x * x + y * y); } #endif