interpolate.cpp
C++ source for Polychorons, 36 lines. Raw file
#include <math.h>
#include "interpolate.h"
//---- interpolateLinear
// Basic linear interpolation
double interpolateLinear( double x1, double x2, double a )
{
return x1*(1.0-a) + x2*a;
}
//---- interpolateSpringy
// with a little wiggle at the end (portion of a sine wave, goes slightly above one, but ends at one)
double interpolateSpringy( double x1, double x2, double a )
{
a = sin( a * 3.14159 * 0.25 * 2.6 ) / sin( 3.14159 * 0.25 * 2.6 );
return x1*(1.0-a) + x2*a;
}