ultimate-nag52-fw/lib/core/tcu_maths.cpp

6 lines
268 B
C++

#include "tcu_maths.h"
float scale_number(float raw, float new_min, float new_max, float raw_min, float raw_max) {
float raw_limited = MAX(raw_min, MIN(raw, raw_max));
return (((new_max - new_min) * (raw_limited - raw_min)) / (raw_max - raw_min)) + new_min;
}