Logo Search packages:      
Sourcecode: inkscape version File versions

static NR::Point sp_darray_center_tangent ( NR::Point const   d[],
unsigned const   center,
unsigned const   len 
) [static]

Estimates the (backward) tangent at d[center], by averaging the two segments connected to d[center] (and then normalizing the result).

N.B. The tangent is "backwards", i.e. it is with respect to decreasing index rather than increasing index.

Precondition:
(0 < center < len - 1) and d is uniqued (at least in the immediate vicinity of center).

Definition at line 780 of file bezier-utils.cpp.

References NR::rot90().

{
    g_assert( center != 0 );
    g_assert( center < len - 1 );

    NR::Point ret;
    if ( d[center + 1] == d[center - 1] ) {
        /* Rotate 90 degrees in an arbitrary direction. */
        NR::Point const diff = d[center] - d[center - 1];
        ret = NR::rot90(diff);
    } else {
        ret = d[center - 1] - d[center + 1];
    }
    ret.normalize();
    return ret;
}


Generated by  Doxygen 1.6.0   Back to index