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.

$\endgroup$
  • $\begingroup$ What is the interval to be used for? There may be a natural way to map speed to interval. $\endgroup$ – Chris Taylor Jun 24 '11 at 17:46
1
$\begingroup$

How about

if speed $\lt$ 0.4 return 0.01

else return 0.004/speed?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.