Logo Search packages:      
Sourcecode: inkscape version File versions

static Point Geom::darray_center_tangent ( 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).

Note:
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 814 of file bezier-utils.cpp.

References Geom::Point::normalize().

Referenced by bezier_fit_cubic_full().

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

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


Generated by  Doxygen 1.6.0   Back to index