how to calculate a negative acceleration?

后端 未结 15 1777
既然无缘
既然无缘 2021-02-08 12:11

I\'m implementing the scrolling behaviour of a touch screen UI but I\'m too tired in the moment to wrap my mind around some supposedly trivial piece of math:

y (         


        
15条回答
  •  难免孤独
    2021-02-08 12:28

    Seems like you are looking for deceleration which increases over time.

    Try computing

    Delta_v = -(A*t + B) , selecting reasonable constants A and B, which suit you.

    t is the total time till that point.

    Change your velocity by adding Delta_v.

    This basically corresponds to linear negative acceleration.

    You can basically select any function which increases over time (say f(t))

    and compute

    Delta_v = -f(t)
    

    An appropriate choice for f(t) would give you the effect you desire.

    Some examples you could use:

    f(t) = At + B.
    f(t) = A*exp(Bt)
    

    Of course, you will have to play around a bit and try to figure out the right constants.

提交回复
热议问题