http://www.cs.princeton.edu/~traer/

traer.animation

This is a simple library for smoothing out the rough edges in interactions. It is basically just a convenient interface for a bunch of normalized one pole lowpass filters that you can use to smooth movements or fade colors.

download traer.animation library for processing, unzip it and put it in /processing/libraries/

feel free to email with questions, comments, suggestions for the library or this documentation or to show me something cool you made with this at traer at cs.princeton.edu, my name is jeff.

If you wanna know how all this works have a look at this section on one pole filters in julius smith's book on digital filters.

Examples

In order of complexity:

Smoother

A smoother is just a normalized one pole filter. It has a smoothness between 0 and less than 1, a target, and a value. The target is where you want it to go, the value is where it is and the smoothness determines how long it takes to get there. 0 smoothness is not smooth at all, i usually use 0.9 which is nice and smooth but the faster your framerate the smoother you will have to make it.

void setSmoothness( float smoothness )
float getSmoothness()

void setTarget( float target )
float getTarget()
It will get to the target eventually

void setValue( float smoothness )
float getValue()
Setting the value makes it jump to this value immediately

Smoother2D

Smoother2D is made of 2 smoothers to smooth 2D movements

void setSmoothness( float smoothness )
float getSmoothness()

void setTarget( float xTarget, float yTarget )
void setXTarget( float xTarget )
void setYTarget( float yTarget )
float getXTarget()
float getYTarget()

void setValue( float xValue, float yValue )
float x()
float y()
void setX()
void setY()

Smoother3D

Smoother3D is made of 3 smoothers to smooth 3D movements

void setSmoothness( float smoothness )
float getSmoothness()

void setTarget( float xTarget, float yTarget, float zTarget )

void setXTarget( float xTarget )

void setYTarget( float yTarget )

void setZTarget( float zTarget )
float getXTarget()
float getYTarget()
float getZTarget()

void setValue( float xValue, float yValue, float zValue )
float x()
float y()
float z()
void setX()
void setY()
void setZ()

Animator

The animator controls all the smoothers. You use it to make smoothers for you and then you tick the animator in draw() to advance time for all the smoothers.

new Animator( float smoothness )
make a new animator with some smoothness

void setSmoothness( float smoothness )
Set the smoothness for all the smoothers

Smoother makeSmoother()
Make a new 1D smoother starting at zero, you can set the value after.

Smoother2D make2DSmoother()
Make a new 2D smoother starting at zero, you can set the value after.

Smoother3D make3DSmoother()
Make a new 3D smoother starting at zero, you can set the value after.

void tick()
advance time for all the smoothers. you'll want to put this in draw.