As I said last week, I’m also using robert penner’s easing equations in openFrameworks, so I’ve ported them to c++.
This has been relatively straightforward, but, as with the actionscript to java conversion, I’ve run into some nuances between languages and I’ve definitely learned the hard way (read “wasting some hours of my life”) why pre and post increment operators can be evil.
For usage, you can have a look at the openFrameworks app provided. If you want to have a quick glance at the types of movement, see the easing applet (p5 version).
Being this a programming exercise, it will have improvable things for sure. I’m thinking of some, but if you know anything, please let me know.
Very nice, and thanks for sharing this. You appear to have an error in the quad function though. All the others are fine, but quad glitches noticeably so the conversion must have gone wrong.
whoops, thanks for spotting it. I’ll look into it and upload the corrected version.
hey phil, can you explain what you see? or if the error is in any or the three easing methods? They seem to be ok on my computer.
best!
[...] http://www.jesusgollonet.com/blog/2007/09/24/penner-easing-cpp/ http://code.google.com/p/cppglue/source/browse/#svn/trunk/ofxCppGlue/src/Animation/Easings [...]
Quad/Out current implementation may lead to errors depending on the compiler. I guess it’s broken on GCC.
Here’s a fix:
t /= d/2;
if(t < 1)
return (1.0/2*t*t);
t–;
return -1.0/2 * (t*(t-2) – 1);
hey thanks rlyeh. no way i’d have guessed that!
I’ll try and fix it asap.
Hello Jesus,
I know your post is a bit old, but I was looking for an implementation of penner easing in c++ to use with openframeworks, and that was exactly what I needed.
I just noticed that the Linear equations (easeNone, easeIn, easeOut and easeInOut) all are the same, is that normal ?
Anyway, thanks a lot for this :)
hey neewok.
yep, the linear “easing” is just absence of acceleration or deceleration, so all the movements have the same behaviour. the reason for having the methods there is just to have consistency with all the other movements.
Btw, although I haven’t touched them in ages, they have a home in github now
http://github.com/jesusgollonet/ofpennereasing/tree/master
best,
jesús.
Muy bueno!!! Muchas gracias…
[...] [...]
[...] in class, we used powf to shape a linear signal. there are more advanced ways to do this (for easing and out, and for snap to, etc). Some of these have been collected by robert penner as “easing equations”. some folks have ported this from AS to c++, you can find them here & here [...]