ocmath_cumulative_curve_length

 

Description

Computes curve's cumulative length.

Syntax

int ocmath_cumulative_curve_length( UINT nSize, double * pCLen, const double * pX, const double * pY, int ntype = NOT_KEEP_STRICT_INCRECE )

Parameters

nSize
[input] size of input curve's X and Y value array.
pCLen
[output] pointer to curve's cumulative length. Its size should be nSize.
pX
[input] pointer to curve's X value array.
pY
[input] pointer to curve's Y value array.
ntype
[input] The cumulative_length method: NOT_KEEP_STRICT_INCRECE and
KEEP_STRICT_INCRECE (used in interpolation_by_parameter).
Its default value is NOT_KEEP_STRICT_INCRECE.

Return

Return OE_NOERROR if succeed, otherwise, non-zero error code is returned.

Examples

EX1

void ocmath_cumulative_curve_length_ex1()
{
    vector vCLen(3); 
    vector vX = {0.1, 0.4, 0.7};
    vector vY = {0.2, 0.6, 1.0};
    int nRet = ocmath_cumulative_curve_length(vCLen.GetSize(), vCLen, vX, vY);
}
// At the end of example: vCLen = {0, 0.5, 1};

EX2

void ocmath_cumulative_curve_length_ex2()
{
    vector vCLen(3); 
    vector vX = {0.1, 0.3, 0.3};
    vector vY = {0.2, 0.4, 0.4};
    int nRet = ocmath_cumulative_curve_length(vCLen.GetSize(), vCLen, vX, vY, KEEP_STRICT_INCRECE);
    if ( vCLen[2] > vCLen[1])
        printf("strict increase");
    else
        printf("not strict increase");
}
// At the end of example: print "strict increase"

Remark

This function computes curve's cumulative length. About result, pCLen[0] will

be 0, pClen[i] will be pCLen[i - 1] + | p(i + 1) - pi |, which pi denotes the ith

point, | p(i + 1) - pi | denotes distance between p(i + 1) and pi.

And if nType == KEEP_STRICT_INCRECE, that is to say pCLen should be monotonic,

so pCLen[i] > pCLen[i - 1] for i = 1,..., nSize - 1. if | p(i + 1) - p(i) | < s,

pClen[i] = pCLen[i - 1] + s, s is a very small numeral: 1e-7.

So if curve's data is very small like: p1 = {1e-10, 2e-10}, p2 = {1.1e-10, 2.1e-10},...,

and its cumulative length array should keep monotonic so as do interpolation use

ocmath_parametric_interpolate_eval. please expanded the data several magnitude

before compute its cumulative length.

See Also

header to Include

origin.h

Reference