2.1.17.2.6.1 Curve_bspline
Description
Create a B Spline curve with optional weighting.
Syntax
int Curve_bspline( curvebase * pcrvData, curvebase * pcrvResults, double dSmoothness = BSPLN_AUTO, Dataset * pdsWeights = NULL )
Parameters
- pcrvData
- [input] source curve
- pcrvResults
- [output] result curve
- dSmoothness
- [input] Smoothness factor can be any arbitrary value >= 0 or a predefined constant (BSPLN_AUTO=-3,BSPLN_INTERPOLATE and BSPLN_WEIGTHED_LEAST_SQUARE_POLYNOMIAL) enumerated in OC_const.h.
- The enumerated constants are negative numbers to distinguish them from arbitrary smoothness factors.
- pdsWeights
- [input] Dataset containing weights for the input curve. If not NULL the number of points in the weight data set must equal the number of points in the source curve. The default weighting is 1 for all points.
Return
Returns zero on successful exit and a non-zero error code on failure.
Errors:
-1=System can not allocate enough memeory
-2=Curve data type error
-4=The result curve range can not be set
5=The smoothness parameter must be equal to or greater than 0
11=The number of data points is less than 4
63=The sequence of X in source data is not increasing
73=Memory allocation failed
240=The weights are not all positive
254=The smoothness parameter is too small
Examples
EX1
// This is a self contained sample program for the function Curve_bspline,
// Its sample data is created at the beginning of the program.
// To run the program, enter the following command in the Script window:
// Curve_bspline_ex1
// It returns like the following line:
// Smoothing Succeeded: Data2==>Data3 Smoothness=0.8
//
void Curve_bspline_ex1()
{
string wksName1,wksName2;
double dSmoothness;
int rc;
Worksheet wksIn, wksOut;
wksIn.Create();
wksOut.Create();
wksName1=wksIn.GetPage().GetName();
wksName2=wksOut.GetPage().GetName();
Dataset myInXDs(wksIn,0);
Dataset myInYDs(wksIn,1);
//******* Create sample data *****************
myInXDs.SetSize(7);
myInYDs.SetSize(7);
myInXDs[0]=1; myInYDs[0]=0.097;
myInXDs[1]=2; myInYDs[1]=0.41256;
myInXDs[2]=3; myInYDs[2]=0.24909;
myInXDs[3]=4; myInYDs[3]=0.47304;
myInXDs[4]=5; myInYDs[4]=0.2476;
myInXDs[5]=6; myInYDs[5]=0.64529;
myInXDs[6]=7; myInYDs[6]=0.44514;
//******** End of Sample Data Creation *******
Curve crvData(wksIn,0,1);
Curve crvResults(wksOut,0,1);
dSmoothness=0.8;
rc = Curve_bspline(&crvData,&crvResults,dSmoothness); //Demonstration of Curve_bspline
if(rc==0)
printf("Smoothing Succeeded: %s==>%s Smoothness=%g\n",wksName1,wksName2,dSmoothness);
else
printf("Smoothing Failed. Error Code=%d\n",rc);
}
Remark
Create a B Spline curve with optional weighting. The smoothness parameter can either be an arbitrary value >= 0 or an enumerated constant. The resulting B Spline curve will copy the source X data set if an empty X data set is provided or it will use a specified X data set as long as the range is within the source X range.
See Also
Header to Include
origin.h
Reference
|