Fit a polynomial equation to a range of a curve.
BOOL fitpoly_range( Curve & cc, int ibeg, int iend, int ipolyorder, double * coeff )
Returns TRUE on success and FALSE on failure.
EX1
bool fitpoly_range_ex1(Curve& crv) { int nBegin = 5; int nEnd = 20; if( nBegin >= crv.GetSize() && nEnd >= crv.GetSize() ) return error_report("nBegin and nEnd too large, please update "); int nPolyOrder = 2; vector vCoeff(nPolyOrder+1); bool bRet = fitpoly_range(crv, nBegin, nEnd, nPolyOrder, vCoeff); if( !bRet ) return error_report("fitpoly_range return false"); for(int ii=0; ii < vCoeff.GetSize(); ii++) printf("%g\n", vCoeff[ii]); return true; } void run_fitpoly_range_ex1() { Worksheet wks = Project.ActiveLayer(); if( wks && wks.GetNumCols() >= 2 ) { Curve crv(wks, 0, 1); fitpoly_range_ex1(crv); } }
The function used for fitting function parameter initialization.
fit_polyline, fitpoly
origin.h