Split the curve to segments and then perform linear fit on them
int ocmath_fit_linear_multi_regions( UINT nSize, const double * px, const double * py, UINT nSegs, const int * pBegs, const int * pEnds, LRresults * pResults )
Return number of linear segments.
EX1
void ocmath_fit_linear_multi_regions_ex1() { vector vx = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; vector vy = {8.15988E-4, 0.01832, 0.16901, 0.64118, 1, 0.64118, 0.16901, 0.01832, 8.15988E-4, 1.49453E-5} vector<int> vBeg = {0, 1, 4, 7}; vector<int> vEnd = {1, 4, 7, 9}; LRresults res[4]; ocmath_fit_linear_multi_regions(10, vx, vy, 4, vBeg, vEnd, res); }
origin.h