In discussion about the equations, it was requested for me to share the code here. This is not a tutorial, I don't have enough familiarity with the subject (or with math in general) to explain how every equation works. I'm just posting what I added to my own code, so others can use it if they want to.
The equations are mostly from Robert Penner's eases, which are under the BSD license. His code seems to be the ones that are used by most software, such as the jQuery, Flash, and other libraries.
Most Ease equations have the function signature:
void equation(currentTime, start, distance, totalTime);
I personally like having my eases in start at 0.0, end at 1.0, and have a 'duration' of 1.0, and then I scale the input and output as desired, instead of having the equation scale it. It just makes it easier for me to understand.
That said, all my functions have the format:
...with 'position' being from 0.0 to 1.0.
Because Eases come in various forms (You can ease IN, OUT, IN and OUT, or OUT and IN), I made sure all the ease equations were in EaseIn form, and I created a few functions to convert the input and output to the other forms as desired.
Here's the conversion code:
http://ideone.com/6rc0Zk ([size=2]Posted as links, because all my code kept getting unformatted when hitting 'publish')
EaseFunction is: "typedef std::function
Some of the ease equations have a few extra parameters, like ElasticEase and BackEase, so I provided some C++11 templates to convert the functions to std::functions that meet the function signature shared by the other functions. It's just a wrapper around std::bind for convenience. (I'm big on convenience! )
You don't have to use C++11 to use the equations! Just the helper functions above.
I also use this function for scaling the output:
Actually, mine looks like this:
...but that depends on a 'FloatRange' helper class I made, whereas the previous one has no dependencies.
I actually made two ScaledEase overloads, one for my Point class, and one for my Color class. I haven't tested those out yet.
I also made a Easer class, that handles most of everything inside of it. This is more for when you want persistent ease data wrapped nicely, and this class would be a member-variable of another class.
That also uses FloatRange, but can be easily adjusted to just use 'float begin' and 'float end' instead.
And here are a few additional ones I keep inline
The next page has graphs generated to test/demonstrate the output.
Cubic Ease In
Cubic Ease InOut
Cubic Ease Out
Cubic Ease OutIn
Elastic Ease In
Elastic Ease InOut
Elastic Ease Out
Elastic Ease OutIn
Exponential Ease In
Exponential Ease InOut
Exponential Ease Out
Exponential Ease OutIn
Linear Ease In / InOut / Out / OutIn
Power Ease In
Power Ease InOut
Power Ease Out
Power Ease OutIn
Quadratic Ease In
Quadratic Ease InOut
Quadratic Ease Out
Quadratic Ease OutIn
Quartic Ease In
Quartic Ease InOut
Quartic Ease Out
Quartic Ease OutIn
Quintic Ease In
Quintic Ease InOut
Quintic Ease Out
Quintic Ease OutIn
Sine Ease In
Sine Ease InOut
Sine Ease Out
Sine Ease OutIn
BounceEase was annoying me alot. I was trying to figure out how it worked, but I'm not very good with math and algorithm-thinking.
The original code looked like this:
And trying to figure out all the magic numbers, I eventually broke it down to this:
I never figured out how the '7.5625f' value was calculated, but the others are resolved.
Unfortunately, changing the value of 'bounciness' or 'bounces' produces poor results (probably from the constant!), so I didn't bother including the code with the rest of the equations.
Links that were useful in understanding and converting the equations:
http://www.robertpenner.com/easing/ (The guy who made most of these now-common equations)
http://sol.gfxile.net/interpolation/index.html (also has good descriptions and explanations)
Some nice graphs: