I have parameters $T$ for tension, $b$ for bounciness and $P_t$ for target value that should be approached as t goes to infinity.
Currently I have written an equation like so:
Which is taken from code that I have written. However, while the code works, this equation does not get me a function that is similar to the results shown by my code. Where have I gone wrong into translating the python code into a mathematical function of time?
This is my code:
g_velocity = 0.0 # note: fr = from, from is just a taken keyword in python def lerp(fr, to, amount): return fr + (amount * (to - fr)) def spring_interp(fr, to, bounciness, tension): global g_velocity g_velocity = lerp(g_velocity, (to - fr) * tension, 1.0 / bounciness) return fr + g_velocity # usage (example values): # the value will then oscillate, dampened over time and approach the target_value value = 1.0 target_value = 8.0 while True: value = spring_interp(value, target_value, 8.0, 0.4) print(value)
Yes, the correct function I am trying to solve would be