www.pudn.com > 3dsMFCRender.rar > LSPLINE.H, change:1998-03-24,size:2422b
#ifndef _LSPLINE_H
#define _LSPLINE_H
#include <afxwin.h> // MFC core and standard components
#include <afxtempl.h>
#include <fstream.h>
#include <math.h>
// The following is used for "smart" new operations
// with tracking during Visual C++ Debug Builds
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
/*
This code may be freely distributed and used in programs so long
as this notice appears in the code.
By Kyle E. Lussier, (lussier@cis.ufl.edu)
(C) 1996 - Silicon Softworks
*/
typedef CArray<float,float> LSplineNumbers;
class LSpline {
LSplineNumbers *t; // range i=0.. (n)
LSplineNumbers *y; // range i=0.. (n)
LSplineNumbers *h; // range i=0.. (n-1)
LSplineNumbers *b; // range i=0.. (n-1)
LSplineNumbers *u; // range i=1.. (n-1)
LSplineNumbers *v; // range i=1.. (n-1)
LSplineNumbers *z; // range i=n.. 0
// Polynomial Coefficients
LSplineNumbers A; // range i=1.. (n)
LSplineNumbers B; // range i=1.. (n)
LSplineNumbers C; // range i=1.. (n)
LSplineNumbers D; // range i=1.. (n)
unsigned lasts;
float lastt;
public:
LSpline() {lasts=0; lastt=0.0; };
~LSpline() {
// t->RemoveAll();
// delete t;
// y->RemoveAll();
// delete y;
};
void Build(); // Build Spline Set
void DisplayEquation(unsigned i);
void Display();
void FreeMemory();
void SetValues(LSplineNumbers *_t, LSplineNumbers *_y) {
t=_t;
y=_y;
N=_y->GetSize()-1;
Init();
};
float operator()(unsigned i, float x);
float operator()(float x);
BOOL IsConstantCase;
private:
void Init();
void Step1();
void Step2();
void Step3();
void Step4();
unsigned N;
int i;
};
typedef CArray<LSpline,LSpline &> LSplines;
class LSmoothMover {
LSplines Set; // Set of Splines
LSplineNumbers *time; // Time series to use
public:
LSmoothMover(unsigned numparams, LSplineNumbers *_t) {
Set.SetSize(numparams);
time=_t;
};
void SetupParamN(unsigned paramnum, LSplineNumbers *_y) {
Set[paramnum].SetValues(time,_y); // set values
if(!Set[paramnum].IsConstantCase)
Set[paramnum].Build(); // build spline
};
float GetValueAtTime(unsigned paramnumb, float t=0) {
return (Set[paramnumb])(t);
};
float GetLastTime() {
int n=time->GetSize();
if(n==0) return 0.0;
return (*time)[n-1]+1;
};
};
#endif