Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

static void Geom::generate_bezier ( Point  bezier[],
Point const   data[],
double const   u[],
unsigned const   len,
Point const &  tHat1,
Point const &  tHat2,
double const   tolerance_sq 
) [static]

Fill in bezier[] based on the given data and tangent requirements, using a least-squares fit.

Each of tHat1 and tHat2 should be either a zero vector or a unit vector. If it is zero, then bezier[1 or 2] is estimated without constraint; otherwise, it bezier[1 or 2] is placed in the specified direction from bezier[0 or 3].

tolerance_sq Used only for an initial guess as to tangent directions when tHat1 or tHat2 is zero.

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

References darray_left_tangent(), darray_right_tangent(), estimate_lengths(), is_zero(), and unit_vector().

Referenced by bezier_fit_cubic_full().

    bool const est1 = is_zero(tHat1);
    bool const est2 = is_zero(tHat2);
    Point est_tHat1( est1
                         ? darray_left_tangent(data, len, tolerance_sq)
                         : tHat1 );
    Point est_tHat2( est2
                         ? darray_right_tangent(data, len, tolerance_sq)
                         : tHat2 );
    estimate_lengths(bezier, data, u, len, est_tHat1, est_tHat2);
    /* We find that darray_right_tangent tends to produce better results
       for our current freehand tool than full estimation. */
    if (est1) {
        estimate_bi(bezier, 1, data, u, len);
        if (bezier[1] != bezier[0]) {
            est_tHat1 = unit_vector(bezier[1] - bezier[0]);
        estimate_lengths(bezier, data, u, len, est_tHat1, est_tHat2);

Generated by  Doxygen 1.6.0   Back to index