6 2 Parametric Curves-2

download 6 2 Parametric Curves-2

of 7

Transcript of 6 2 Parametric Curves-2

  • 8/12/2019 6 2 Parametric Curves-2

    1/7

    Computer Graphics()

    C. F. Chang, 2003

    Convex hull ( ) property Theconvex hullof a set of pointsSin n dimensions is the intersection of all

    convex sets containingS. ForNpoints P1, ..., PN, the convex hullCis then given

    by the expression

    The convex hull property ensures thata parametric curve will never pass

    outside of the convex hullformed by the four control vertices. As such, it lends

    a measure of predictability to the curve.

    TheBezier basis functions satisfythe conditions necessary for the convex hull

    property, namely:

    0 fi(u) 1 foru in [0,1]. f1(u) + ... +fn(u) = 1

    Bezier Curves of degreen

    It is not per chance that the basis functions for Bezier curves have the convex hull

    property. How might one then go about designing a set of basis functions that sum to

    one and ensure that each individual basis function remain in the range [0,1]? The

    Bernstein polynomialshave exactly the required properties.

    Using the Bernstein polynomials, we can construct a Bezier curve of arbitrary degree.

    For curves of higher degree than the cubic Bezier curve, we'll need more than fourcontrol points. The general Bezier curve of degree n is given by

    P(u) = n

    i ini PuB

    0 , )(

    where inini uui

    nuB

    )1()(, is called Bernstein basis function, it satisfies

    n

    i

    n

    ni uuuB0 , 1])1[()( .:n! / [i!(n-i)!]

  • 8/12/2019 6 2 Parametric Curves-2

    2/7

    Computer Graphics()

    C. F. Chang, 2003

    That means the basis functions are equivalent to the terms arising from the expansion

    of

    [u + (1-u) ]n

    using the binomial expansion theorem(). It is also obvious from this whythe sum of all the terms is equal to one.

    Piecewise Hermite and Bezier Curves

    Hermite curve segments can be connected in a continuous fashion by ensuring that the

    end-point of one curve is the same as the starting point of another, as well as ensuring

    that the tangent vectors for this point have the same direction.

    T1

    P1

    P4, P

    1P4 T

    4

    T4, T

    1

    In terms of the above figure, this meansP1'=P4, T1'=k T4.

    For a Bezier curve, the conditions are that the last two points of one curve and the first

    two points of the second curve are aligned.

    Geometric and Parametric Continuity

    Geometric Continuity

    G0: curves are joined G1: the first derivatives of curves areproporti onal at the join point

    The curve tangents of the curves thus have the same direction, but not

    necessarily the same magnitude.

    G2: the first and second derivatives are proportional at join point

    Parametric Continuity

    C0: curves are joined

    C1: first derivatives areequal

    C2: first and second derivatives are equalIfu is taken to be time, this implies that the acceleration is continuous.

    Cn:nth derivatives areequal

  • 8/12/2019 6 2 Parametric Curves-2

    3/7

    Computer Graphics()

    C. F. Chang, 2003

    As their names imply, geometric continuity requires the geometry to be continuous,

    while parametric continuity requires that the underlying parameterization be

    continuous as well.

    Parametric continuity of order n impliesgeometric continuity of order n, but not

    vice-versa.

    Summary of Bezier and Hermite Curves

    offer local control

    offer C1 continuity

    interpolates (some) control points

    Splines

    splinesare cubic curves which maintain C2 continuity.

    natural spline

    o interpolates all of its control points.

    o equivalent to a thin strip of metal forced to pass through control points

    o no local control

    B-spline(A generation of Bzier curve)

    o local controlo does not interpolate control points

    The following is an example of a four-segment B-spline curve. The points that

    indicate the ends of the individual curve segments and thus the join points are known

    as theknots.

  • 8/12/2019 6 2 Parametric Curves-2

    4/7

    Computer Graphics()

    C. F. Chang, 2003

    KnotControl point

    Each curve segmentQ is determined by four control points, as follows:

    P0 P1 P2 P3 P4 P5 P6

    Q1Q2

    Q3 Q4

    B-spline curves are defined by a basis matrix, just like the other types of cubic curves.

    MBspline=

    0141

    0303

    0363

    1331

    6

    1

    where the geometry vector consists of four consecutive control points. It is easy to

    show that B-spline curves areC2 continuous and that they satisfy the convex-hull

    property.

    In the following is the general form of a B-spline havingm+1 control points, P0,

    Pm, andm-2 segments,Q3, Qm.

    i

    i

    i

    i

    Bsplineiiii

    P

    P

    P

    P

    uuuuuuuQ

    1

    2

    3

    123 1)()()()( M , uiu < ui+1

    The entire curve is generated by applying this equation for 3 im. If expanding theequation, and replacingu-uiwitht, we have

    Qi(t)=[(1-t)3/6]Pi-3+[(3t

    3-6t2+4)/6]Pi-2+[(-3t3+3t2+3t+1)/6]Pi-1+[t

    3/6]Pi,0t< 1

  • 8/12/2019 6 2 Parametric Curves-2

    5/7

    Computer Graphics()

    C. F. Chang, 2003

    The basis functions for the B-spline are as follows:

    t f1(t) f2(t) f3(t) f4(t)

    0 0.1666667 0.666667 0.166667 00.1 0.1215 0.657167 0.221167 0.00017

    0.2 0.0853333 0.630667 0.282667 0.00133

    0.3 0.0571667 0.590167 0.348167 0.00450.4 0.036 0.538667 0.414667 0.010670.5 0.0208333 0.479167 0.479167 0.020830.6 0.0106667 0.414667 0.538667 0.0360.7 0.0045 0.348167 0.590167 0.057170.8 0.0013333 0.282667 0.630667 0.085330.9 0.0001667 0.221167 0.657167 0.12151 0 0.166667 0.666667 0.16667

    0

    0.2

    0.4

    0.6

    0.8

    1

    t0.1

    0.3

    0.5

    0.7

    0.9

    f1(t)f2(t)f3(t)f4(t)

    AB-spline isUniformif its internal knots are equally spaced

    A B-spline with no internal knots is a Bzier curve

    Multiple knots

    Control vertices can be repeated in order to allow for reduced geometric continuity at

    the join points.

    Multiplicity

    1 G2 continuous

    2 G1 continuous

    3 G0 continuous, interpolates point

    A

    G

    D

    E

    CF

    B

    Double knot at D

    Single knot at D

    NURBS:NonuniformRationalB-splines

    One of the disadvantages of the curves discussed to date is that they cannot be used to

    create commonconic shapessuch ascircles,ellipses,parabolas, etc. This can be done

    using rational cubic curves, however.

  • 8/12/2019 6 2 Parametric Curves-2

    6/7

    Computer Graphics()

    C. F. Chang, 2003

    Generalrationalcubic curve segments are ratios of polynomials:

    x(u) = X(u)/W(u)

    y(u) = Y(u)/W(u)

    z(u) = Z(u)/W(u)

    where X(u), Y(u), Z(u), and W(u) are cubic polynomial curves whose control points

    are defined in homogeneous coordinates. Defining curves as rational polynomials in

    this manner allows for simpleexactrepresentations of conic sections such as circles,

    as well as curves that are invariant under perspective projection.

    SAMPLE CODE FOR DRAWING BEZIER CURVE

    #include

    void computeCoefficients (int n, int * c){

    int k, i;

    for (k=0; k=k+1; i--)

    c[k] *= i;

    for (i=n-k; i>=2; i--)

    c[k] /= i;

    }

    }

    void computePoint (float u, Point3 * pt, int nControls, Point3 * controls, int * c)

    {

    int k, n = nControls - 1;

    float blend;

    pt->x = 0.0; pt->y = 0.0; pt->z = 0.0;

    /* Add in influence of each control point */

    for (k=0; kx += controls[k].x * blend;

    pt->y += controls[k].y * blend;

    pt->z += controls[k].z * blend;

    }

    }

  • 8/12/2019 6 2 Parametric Curves-2

    7/7

    Computer Graphics()

    C. F. Chang, 2003

    void bezier (Point3 * controls, int nControls, int m, Point3 * curve)

    {

    /* Allocate space for the coefficients */

    int * c = (int *) malloc (nControls * sizeof (int));

    int i;

    computeCoefficients (nControls-1, c);

    for (i=0; i