#ifndef NUMBER_UTILS_H #define NUMBER_UTILS_H #include #include // Map a value with range, to another range. template T mapRange(T value, T inMin, T inMax, T outMin, T outMax) { static_assert(std::is_arithmetic::value, "Template parameter must be a numeric type"); if (inMin == inMax) { return value; } return (value - inMin) * (outMax - outMin) / (inMax - inMin) + outMin; } #endif //NUMBER_UTILS_H