Logo Search packages:      
Sourcecode: inkscape version File versions

static NR::Point bezier_pt ( unsigned const   degree,
NR::Point const   V[],
gdouble const   t 
) [static]

Evaluate a Bezier curve at parameter value t.

Parameters:
degree The degree of the Bezier curve: 3 for cubic, 2 for quadratic etc.
V The control points for the Bezier curve. Must have (degree+1) elements.
t The "parameter" value, specifying whereabouts along the curve to evaluate. Typically in the range [0.0, 1.0].
Let s = 1 - t. BezierII(1, V) gives (s, t) * V, i.e. t of the way from V[0] to V[1]. BezierII(2, V) gives (s**2, 2*s*t, t**2) * V. BezierII(3, V) gives (s**3, 3 s**2 t, 3s t**2, t**3) * V.

The derivative of BezierII(i, V) with respect to t is i * BezierII(i-1, V'), where for all j, V'[j] = V[j + 1] - V[j].

Pascal's triangle.

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

Referenced by compute_hook(), compute_max_error_ratio(), and NewtonRaphsonRootFind().

{
    /** Pascal's triangle. */
    static int const pascal[4][4] = {{1},
                                     {1, 1},
                                     {1, 2, 1},
                                     {1, 3, 3, 1}};
    g_assert( degree < G_N_ELEMENTS(pascal) );
    gdouble const s = 1.0 - t;

    /* Calculate powers of t and s. */
    double spow[4];
    double tpow[4];
    spow[0] = 1.0; spow[1] = s;
    tpow[0] = 1.0; tpow[1] = t;
    for (unsigned i = 1; i < degree; ++i) {
        spow[i + 1] = spow[i] * s;
        tpow[i + 1] = tpow[i] * t;
    }

    NR::Point ret = spow[degree] * V[0];
    for (unsigned i = 1; i <= degree; ++i) {
        ret += pascal[degree][i] * spow[degree - i] * tpow[i] * V[i];
    }
    return ret;
}


Generated by  Doxygen 1.6.0   Back to index