Applying scrolling physics to an app
I believe this is a fairly simple question but I have no idea where to start.
I'm trying to implement a feat开发者_C百科ure where an entity (such as an image) can be flicked across the screen such that it decelerates over time based on an initial speed (non-zero) and coefficient of friction.
In other words, given an initial velocity and constant friction, how can I programmtically determine where an object will be at time t??
Feel free reply using pseudo-code or any programming language you're comfortable with.
Thanks guys
The equation is
s = u*t + 0.5*a*t*t
where,
s is displacement (i.e. position)
u is the initial speed (can be zero too actually)
a is the acceleration (if you want deceleration use a negative value instead)
t is the time elapsed
To account for friction your a
will be (on a horizontal surface)
a = -μg
where,
μ is the coefficient of friction
g is gravitational acceleration
精彩评论