Saturday, 3 April 2021

Calculate deceleration based on velocity and grid

I'm trying to calculate the decay or velocity in a requestFrame loop based on the fact that I know the velocity (v) and the distance I want to travel. I also know the ms for each frame.

So a simple decay algorithm is:

velocity *= 0.9

This slows down smooth and nicely. But I want the animated element to stop at a given position (snap to grid). So how can I calculate the deceleration accurately?



from Calculate deceleration based on velocity and grid

No comments:

Post a Comment