Logo Search packages:      
Sourcecode: inkscape version File versions

Point Geom::darray_left_tangent ( 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 752 of file bezier-utils.cpp.

References darray_left_tangent(), and unit_vector().

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


Generated by  Doxygen 1.6.0   Back to index