how to calculate a negative acceleration?

后端 未结 15 1757
既然无缘
既然无缘 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:38

    If you want increasing deceleration as you say in your comment at mtrw's answer, and you are NOT very picky about physical realism, the equation below may be what you're looking for:

    V(t+dt) = V(t) - K1 + K2 x V(t)

    V(t)= current speed V(t+dt)= speed at next time increment K1 and K2 are constants you calibrate. Just make sure (K2 x Vmax) < K1, or you'll accelerate at high speeds.

    If it still doesn't feel right, try V(t+dt) = V(t) - K1 + K2 x f(V(t))

    where f(x) is a monotonically increasing function you pick, maybe square or square root depending of where you want to take the feeling. Just make sure (K2 x f(V(t))) < K1 for every possible V(t).

    (monotonically increasing function means f(x) always increases when x increases)

提交回复
热议问题