Logo Search packages:      
Sourcecode: inkscape version File versions

static void generate_bezier ( NR::Point  bezier[],
NR::Point const   data[],
gdouble const   u[],
unsigned const   len,
NR::Point const &  tHat1,
NR::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].

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

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

References sp_darray_left_tangent(), and sp_darray_right_tangent().

{
    bool const est1 = is_zero(tHat1);
    bool const est2 = is_zero(tHat2);
    NR::Point est_tHat1( est1
                         ? sp_darray_left_tangent(data, len, tolerance_sq)
                         : tHat1 );
    NR::Point est_tHat2( est2
                         ? sp_darray_right_tangent(data, len, tolerance_sq)
                         : tHat2 );
    estimate_lengths(bezier, data, u, len, est_tHat1, est_tHat2);
    /* We find that sp_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