00001 // spline.h 00002 // Functions for reading b-spline parameters from file and evaluating 00003 // b-splines. 00004 // Author: Clay Anderson 00005 // Creation Date: 2000_07_28 00006 00007 00008 // SO THAT ROUTINES MAY BE CALLED FROM C 00009 #ifdef __cplusplus 00010 extern "C" { 00011 #endif 00012 00013 //============================================================================== 00014 // INCLUDES 00015 //============================================================================== 00016 00017 00018 //============================================================================== 00019 // DEFINES 00020 //============================================================================== 00021 #define MAXSIZE 256 00022 00023 //============================================================================== 00024 // TYPEDEFS 00025 //============================================================================== 00026 //______________________________________________________________________________ 00030 typedef struct { 00031 char name[MAXSIZE]; 00032 int order; 00033 int nknots,ncoefs; 00034 double ti,tf; 00035 double knots[MAXSIZE]; 00036 double coefs[MAXSIZE]; 00037 } SplineStruct; 00038 00039 00040 //============================================================================== 00041 // METHODS 00042 //============================================================================== 00043 00044 //------------------------------------------------------------------------------ 00045 // CONSTRUCTION 00046 //------------------------------------------------------------------------------ 00047 SplineStruct* constructSpline(FILE *fp); 00048 00049 //------------------------------------------------------------------------------ 00050 // EVALUATION 00051 //------------------------------------------------------------------------------ 00052 double spval(SplineStruct *sp,double x); 00053 double s(SplineStruct *sp,double x); 00054 double b(double *k,int i,int n,double x); 00055 double evaluateSpline(SplineStruct *sp, double x); 00056 00057 //------------------------------------------------------------------------------ 00058 // UTILITY 00059 //------------------------------------------------------------------------------ 00060 int knotIndex(SplineStruct *sp,double x); 00061 void printSpline(SplineStruct *sp); 00062 00063 //------------------------------------------------------------------------------ 00064 // HIGH-LEVEL ROUTINES FOR QUERRYING A SUITE OF SPLINES 00065 //------------------------------------------------------------------------------ 00066 int constructsplinesuite_(char *aBaseName,int &aN); 00067 void destroysplinesuite_(); 00068 double sppos_(int &aN,double &aT); 00069 double spvel_(int &aN,double &aT); 00070 double spacc_(int &aN,double &aT); 00071 bool isStateIndexValid(int aI); 00072 00073 00074 //------------------------------------------------------------------------------ 00075 // TESTING 00076 //------------------------------------------------------------------------------ 00077 void testHighLevel(); 00078 void testSplineEvaluations(); 00079 00080 00081 #ifdef __cplusplus 00082 } 00083 #endif 00084 00085 00086 00087
1.3