Penner easing for c++

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.

Grab them here

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.

tags:

8 Responses to “Penner easing for c++”

  1. Phil Says:

    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.

  2. jesus gollonet Says:

    whoops, thanks for spotting it. I’ll look into it and upload the corrected version.

  3. jesus gollonet Says:

    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!

  4. makingThingsMove » homework 2 Says:

    […] 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 […]

  5. rlyeh Says:

    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);

  6. jesus gollonet Says:

    hey thanks rlyeh. no way i’d have guessed that!

    I’ll try and fix it asap.

  7. Neewok Says:

    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 :)

  8. jesus gollonet Says:

    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.

Leave a Reply