Logo Search packages:      
Sourcecode: inkscape version File versions

NR::Point sp_darray_right_tangent ( NR::Point const   d[],
unsigned const   len,
double const   tolerance_sq 
)

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

N.B. 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 750 of file bezier-utils.cpp.

References sp_darray_right_tangent().

{
    g_assert( 2 <= len );
    g_assert( 0 <= tolerance_sq );
    unsigned const last = len - 1;
    for (unsigned i = last - 1;; i--) {
        NR::Point const pi(d[i]);
        NR::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
                     ? sp_darray_right_tangent(d, len)
                     : unit_vector(t) );
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index