Logo Search packages:      
Sourcecode: inkscape version File versions

Point Geom::darray_right_tangent ( Point const   d[],
unsigned const   len,
double const   tolerance_sq 
)

Estimates the (backward) tangent at d[last].

Note:
The tangent is "backwards", i.e. it is with respect to decreasing index rather than increasing index.
Precondition:
2 <= len.

d[len - 1] != d[len - 2].

all[p in d] in_svg_plane(p).

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

References darray_right_tangent(), and unit_vector().

{
    assert( 2 <= len );
    assert( 0 <= tolerance_sq );
    unsigned const last = len - 1;
    for (unsigned i = last - 1;; i--) {
        Point const pi(d[i]);
        Point const t(pi - d[last]);
        double const distsq = dot(t, t);
        if ( tolerance_sq < distsq ) {
            return unit_vector(t);
        }
        if (i == 0) {
            return ( distsq == 0
                     ? darray_right_tangent(d, len)
                     : unit_vector(t) );
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index