The values are correct at start and end points, but jump to massively incorrect ranges in-between.
The math is wrong:
float magicNumber = -(toMax - toMin) / 2;
wanting a smooth transition from 0 to 90 you get:
magicNumber = -(90-0)/2 = -45
It follows:
cos(t) * magicNumber + magicNumber + toMin = 1 * (-45) - 45 + 0 = -90.0
So at time 0.001 (time 0 is guarded) your smooth 0 to 90° function jumps at -90°, which is what happened to me trying to use it.
same error in smoothReturnToRange(). (The rest seems fine)
The values are correct at start and end points, but jump to massively incorrect ranges in-between.
The math is wrong:
float magicNumber = -(toMax - toMin) / 2;wanting a smooth transition from 0 to 90 you get:
magicNumber = -(90-0)/2 = -45It follows:
cos(t) * magicNumber + magicNumber + toMin = 1 * (-45) - 45 + 0 = -90.0So at time 0.001 (time 0 is guarded) your smooth 0 to 90° function jumps at -90°, which is what happened to me trying to use it.
same error in smoothReturnToRange(). (The rest seems fine)