Logo Search packages:      
Sourcecode: inkscape version File versions

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

Estimate the (forward) tangent at point d[0].

Unlike the center and right versions, this calculates the tangent in the way one might expect, i.e. wrt increasing index into d.

Precondition:
2 <= len.

d[0] != d[1].

all[p in d] in_svg_plane(p).

Postcondition:
is_unit_vector(ret).

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

References sp_darray_left_tangent().

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


Generated by  Doxygen 1.6.0   Back to index