remap range:
double fit(double index, double old_min, double old_max, double new_min,double new_max)
{
return new_min + (new_max - new_min) * (index - old_min) / (old_max- old_min);
}
usage :
fit(0.5, 0, 1, 10, 20);
>> 15.0
>>
LERP:
Precise method which guarantees v = v1 when t = 1.
float lerp(float v0, float v1, float t)
{
return (1-t)*v0 + t*v1;
}
Nenhum comentário:
Postar um comentário