so I'm creating a billiard ball simulation. The current version I have calculates the new position of the ball for each step, but I would like to create a math function (f(x)) for the balls position. This is not too hard, but what is really tripping me out is getting it to work with friction.
For the ball I have the following relevant information: Speed/velocity, position/startpos and friction coefficient. I am able to calculate the distance the ball moves in a single step by raising the friction coeff to the power of x. The problem is that I can only get it to work by calculating the new position step by step. I have illustrated it in Ti-Nspire:



If this is in the end is harder and less efficient that just updating each second, please let me know. If you have a solution to how I could get it as a function or a better solution, please let me know too. Thanks for any help in advance:)
Having the velocity diminish proportionally to its current magnitude in continuous time (vs. discrete time steps) is pretty much the definition of exponential decay. That means the continuous time function corresponding to your discrete-stepped scaling would be
where V0 is the initial velocity at time 0 and λ is the rate of decay. We need to calibrate the decay rate to correspond with your friccoef, which means we want
and thus
yielding
We can then derive the distance covered as a function of time t by integrating the velocity from 0 to t. The resulting formula for the position at time t, if movement starts at time t0 with velocity Vt0 and initial location Xt0, is
To show the continuous time evolution of the function I used gnuplot with t0 = 0, V0 = 32, X0 = 123, and friccoef = 0.9:
Bringing it back around to stackoverflow relevance, the formulae above can be implemented straightforwardly in Python:
A few simple test cases...
produce the following output: