Mike’s Brain

Just ticking away…

Mike’s Brain header image 2

Smoothstep interpolation for motion control

March 8th, 2009 by Mike

“Adding little smoothness to all kinds of movement, be it actual movement of the camera, some object, fading of lights, fading in and out etc, makes things much more enjoyable to watch. Sharp movements and changes are jarring and should be avoided.

danthompsonsblog.blogspot.com/2009/02/smoothstep-interpolation-with-arduino.html
sol.gfxile.net/interpolation/index.html

For example, X ranges between points A and B in N steps.

With linear interpolation:

 for (i = 0; i < N; i++)
 {
   v = i / N;
   X = (A * v) + (B * (1 – v));
 } 

With smoothing:

#define SMOOTHSTEP(x) ((x) * (x) * (3 – 2 * (x)))
for (i = 0; i < N; i++)
 {
   v = i / N;
   v = SMOOTHSTEP(v);
   X = (A * v) + (B * (1 – v));
 }

Tags:   · · No Comments

Leave a Comment

You must log in to post a comment.

0 responses so far ↓

There are no comments yet...Kick things off by filling out the form below.