One method is to use list-based interpolations
float lerps( float amt, float... vals) {
if(vals.length==1){ return vals[0]; }
float unit = 1.0/(vals.length-1);
return lerp(vals[floor(amt / unit)], vals[ceil(amt / unit)], amt%unit/unit);
}
So my time / vals will be like this:
0 1.5
100 1.5
200 1.5
300 1.5
400 1.5
500 2.0
So my amt, which ranges 0-1.0, will be time/500.0
and my vals will be new float[] {1.5, 1.5, 1.5, 1.5, 1.5, 2.0}
With that, lerps() will return the correct results for e.g. time = 450 (1.75)
For more, see: