/** @file spline.h @maintainer Morgan McGuire, http://graphics.cs.williams.edu @created 2004-07-25 @edited 2007-05-05 */ #ifndef G3D_SPLINEFUNC_H #define G3D_SPLINEFUNC_H #include "G3D/platform.h" #include "G3D/debug.h" #include "G3D/Array.h" #include "G3D/g3dmath.h" namespace G3D { /** Interpolates a property according to a piecewise linear spline. This provides C0 continuity but the derivatives are not smooth.
Example:
const double times[] = {MIDNIGHT, SUNRISE - HOUR, SUNRISE, SUNRISE + sunRiseAndSetTime / 4, SUNRISE + sunRiseAndSetTime, SUNSET - sunRiseAndSetTime, SUNSET - sunRiseAndSetTime / 2, SUNSET, SUNSET + HOUR/2, DAY};
const Color3 color[] = {Color3(0, .0, .1), Color3(0, .0, .1), Color3::black(), Color3::black(), Color3::white() * .25, Color3::white() * .25, Color3(.5, .2, .2), Color3(.05, .05, .1), Color3(0, .0, .1), Color3(0, .0, .1)};
ambient = linearSpline(time, times, color, 10);
See also G3D::Spline
@param x The spline is a function of x; this is the sample to choose.
@param controlX controlX[i], controlY[i] is a control points. It is assumed
that controlX are strictly increasing. XType must support
the "<" operator and a subtraction operator that returns
a number.
@param controlY YType must support multiplication and addition.
@param numControl The number of control points.
*/
template