fitpoly_range

 

Description

Fit a polynomial equation to a range of a curve.

Syntax

BOOL fitpoly_range( Curve & cc, int ibeg, int iend, int ipolyorder, double * coeff )

Parameters

cc
[input] curve to fit
ibeg
[input] beginning index to fit
iend
[input] ending index to fit
ipolyorder
[input] degree of polynomial equation
coeff
[output] array containing parameter coefficients

Return

Returns TRUE on success and FALSE on failure.

Examples

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);
        }
}

Remark

The function used for fitting function parameter initialization.

See Also

fit_polyline, fitpoly

header to Include

origin.h

Reference