Say I have a timeline beginning at 0 and ending at 1. I have several points along the timeline and I want to lerp between them over time. e.g. pt1 to pt2, pt2 to pt3, pt3 to pt1. Once the value reachs 1, loop back to 0. But, the percentage from 1 back to 0 must be maintained.
So think of variable
t as the current time on a clock between 0 and 1 and
b are points on the timeline.
a = 0.33 b = 0.5 t = 0.42
Finding what percentage
t is between
"given number x in range between a and b, percentage = x - a / b - a." 0.42 is 53% between 0.33 and 0.5
t == b, the lerp between the two numbers should be 100%. Once this happens,
a becomes 0.5,
b becomes 0.33, and
t continues as it was.
a = 0.5 b = 0.33 t = 0.72
The formula would not work the same because once it loops back passed 1 and becomes something like 0.3, it breaks. The distance between
b is 0.83(
(1 - 0.5) + 0.33), so 0.3 should be somewhere like 80-90%. How would I find this?