Ok I am hoping to apply this answer to a piece of software, but it uses physics to work out the result so I require some help in that department.
I will attempt to explain this the best I can.
I need to work out the continual position of a scrolling list. If you were to flick the list it would continue to scroll (without the user touching it) for set amount of time decelerating as it does this.
The information I can gather.
- The start position of the users touch
- The end position of the users touch
- The distance between the touches
- Believe I can then get the speed of this (speed = distance/time)
- The continual time the scroll will last after the touch is 2400ms
I have read that the deceleration of the scroller happens every 325ms at a factor of 0.95 targeting a fps of 60. Giving this 325 is -16.7 / ln(0.95). Though I do not know is this is correct.
I really need to know, the point that the scroller will stop after the 2400ms and ideally an update of the current position every 100ms. I just need to know the physics behind this as the programming will be simple from there.
Edit
I think that the scroller velocity does reduce at a factor of 0.95 every 325ms. I have found this information from this useful article.
This observation led me to believe that the momentum scrolling is a sort of exponential decay. It is characterized by the speed of the decay. There are two different ways to express it: half-life (remember radioactive decay?) or time constant. For the latter, it is very much related to the step response of a first order system. In other words, the deceleration system is just an overdamped spring-mass system. Turns out, everything is still based on physics.
amplitude = initialVelocity * scaleFactor;
step = 0;
ticker = setInterval(function() {
var delta = amplitude / timeConstant;
position += delta;
amplitude -= delta;
step += 1;
if (step > 6 * timeConstant) {
clearInterval(ticker);
}
}, updateInterval);
In fact, this is how the deceleration is implemented in Apple’s own PastryKit library (and now part of iAd). It reduces the scrolling speed by a factor of 0.95 for each animation tick (16.7 msec, targeting 60 fps). This corresponds to a time constant of 325 msec. If you are a math geek, then obviously you realize that the exponential nature of the scroll velocity will yield the exponential decay in the position. With a little bit of scriblling, eventually you find out that 325 is -16.7 / ln(0.95).
This Google Doc should show the formulas and hopefully I am doing it correctly. On the left is the standard formula. On the right I have attempted to reduce the velocity by 0.95 (velocity*0.95). I have added real information from my testing to show the problem I am having. If all the equations are correct and it being done the correctly logically way, I must be the data going in.