Animation Ration Equation

Started by
3 comments, last by Wolfdog 17 years, 11 months ago
I am doing animation based on time in seconds. Every frame I increase the number of seconds that have gone by using QueryPerformanceCounter so it is quite accurate. For animation purposes I use the amount that has gone by sense the animation started over the amount of time the animation is supposed to take. This gives me a ratio between 0.0 and 1.0 that I use to Interpolate the Animation. The problem is that it feels kindof dead or static, there is no acceleration involved. If I were to graph my current equation for doing animation it would be the time ratio on the x axis and the Animation Ratio on the y axis. Currently the graph would be y = x. A diagonal line. I think what I need is a graph that would resemble more of a porabla up until it gets near the time of 1.0 then it would slowly level out. Anyone know the equation, or even where to look to create this kind of acceleration effect. I tried a sin wave but that of course goes slowly accelerating to 1.0 or it accelerates to one then decelerates to 0.0, I need it to accelerate to the middle go fast for a short period then deaccelerate. I hope all that made sense.
Advertisement
y = sin(x*pi/2) will give you an animation that eases in and out. There are more complicated curves you can use, but this works fine and has a simple explicit solution (unlike some of the more complicated curves, which are expressed as differential equations).
Thanks for your reply.

The sin equation dosent excatly give me what I need. That equation eases from 0.0 to 1.0 then back to 0.0. I need one that starts slowly from 0.0 then moves to fast then slows down again as it approches 1.0.
Quote:That equation eases from 0.0 to 1.0 then back to 0.0.
No it doesn't. Within the domain [0,1] the function y=sin(x*pi/2) starts at 0 and ends at 1. if it goes back down to 0, you're probably forgetting the /2.
Your absolutly right, thank you. That solved my problem.

This topic is closed to new replies.

Advertisement