0
$\begingroup$

I'm creating an app and this app has gesture controlled animation. I'm working on a deceleration algorithm, but I'm having a little trouble with a calculation.

I have a timer served by an interval (in seconds) and I have a speed of gesture swipe. I'm having a little trouble getting the initial time interval the first time the timer fires an event.

I somehow need to map speed to interval to begin deceleration.

At it's fastest, speed is 4000 and when speed is 4000 I wish to return an interval of 0.000001 - the smallest time interval and therefore the timer will fire faster.

At it's slowest, speed is 0 and when speed is 0 I wish to return an interval of 0.01 - the largest time interval and therefore the timer will fire slower.

Thanks for any help you may give me.

  • 0
    What is the `interval` to be used for? There may be a natural way to map `speed` to `interval`.2011-06-24

1 Answers 1

1

How about

if speed $\lt$ 0.4 return 0.01

else return 0.004/speed?