# CS 284: CAGD  Lecture #4 -- Tue 9/04, 2012.

PREVIOUS < - - - - > CS 284 HOME < - - - - > CURRENT < - - - - > NEXT

## Preparation:

Rockwood: pp 59-73.

## Review:

• High-order Bézier curves are not a good approach; they do not allow much real control.
Their basis functions have too wide a support area; they affect all points of the curve.
• B-splines (to be discussed soon) have basis functions with local control, so it is easier to introduce local wiggles into a curve.
However, they are approximating; thus, while they give good continuity, they do not interpolate the control points.
• Therefore, we will make a composite curve by stitching together (with the desired continuity) many low-order curve segments,
-- either cubic or quintic Bézier curves, -- or cubic or quintic Hermite spline segments.
• When stitching together Bézier curves, we match endpoints to get C0 continuity;
align the next control points to get G1 or C1 continuity (also match distances for the latter case);
and perhaps also adjust the second-nearest control points to obtain G2 or C2 continuity, -- but this gets complicated and tedious.
Also, when we we want G2 continuity at both end of a cubic Bézier curves, the inner control points receive constraints from both ends!
It is then much better to use quintic Bézier curves, so control points can be adjusted by looking in only one direction. (It is still tedious!).
• Hermite splines make this stitching-together easier, because they encode the derivative conditions at the ends directly.

## Stitching Bézier Curves Together -- what choices do we have ?

• Counting Degrees of Freedom (DoF)
• Each control point in R2 has 2 DoF.
• Each constraint imposed removes one DoF. Matching 2 points in R3 (in x, y, and z) removes 3 DoF.
• How many DoF are remaining in a closed composite curve with N cubic Bézier segments ?
• (3N for G1;  or 2N for C1;  or 2N for G2). == Refer to warm-up problem!
• How do we make use of these DoF ?
• Optimize the curve !
• E.g., make it as "pleasing" as possible: --> See Programming Assignment #1.
• Find a good automated heuristic to place the extra control points.

• Possibility of Global Optimization  -- NOT part of your assignment!
• Define a cost function:
• E.g., Bending Energy = arc-length integral of square of curvature,
and approximate this as best possible with the available Bézier segments.
• How can this be done?
• Find out how each DoF affects the total Energy (e.g., by doing finite differences);
• All these derivatives form components an overall gradient vector in DoF-dimensional space;
• Move along this gradient vector towards a local minimum in energy.
• A specific example: Make a "pleasing" (low bending energy) figure 8 curve from just two cubic Bezier segments.
• How to set up the first guess ?
• How many DoF?
• At first it looks like 2 ... one for shape and one for scale ...
• but there may be a scaling instability for MECs (minimum energy curves)! ==> Keep curve size roughly constant.
• How to adjust the DoF?
• Evaluate the energy for the shape parameter value,
• do a binary search for a minimum.

## (Cubic) Hermite Splines

• Another - practical - way of making interpolating curves.
• Review Basis Functions (page 70) -- again, they span the whole range of the segment.
• If all direction vectors are given at all points:
• -- proceed just like for Bezier segments.
• If we don't care explicitly about the directions at the joints (and leave this open for shape optimization):
• -- Can we "buy" something else ? e.g. G2 or C2 continuity ?
-- Let's count DoF; assuming N points in D-dimensional space, cubic curve segments between them:
• each cubic function has 4 parameters for each of  D coordinates: a + bt + ct2 + dt3; this yields 4D(N-1)  DoF overall;
• at each of the (N-2) inner joints, we loose some DoF for matching:  D * ( t-value, position, first derivative, second derivative, ...)
• for an open-ended curve, 2D  DoF are left over.
• Things to do with the spare DoF:
• -- Pick initial velocity
-- Pick initial and final tangent direction
-- Pick initial and final curvature ...
• often chosen to be zero  at free ends  ==> "natural" spline.
• What if curve is closed ("periodic") ?
• -- Adds  2D  more constraints.
-- NO  DoF left !
-- Exercise in equation solving. {see Chapter 3 in Bartels+Beatty+Barsky "Splines" book, pp 9-17}

### Higher-Order Hermite Splines

• They allow to specify higher-order derivatives at the joints, e.g., acceleration, or curvature;
• Quintic Hermite Splines are quite useful; they allow to specify position, first derivative (velocity), second derivative (acceleration, curvature) at each joint.
• To make "good-looking" C2-continuous interpolating curves, use some heuristic to set those values based on "local" information.

# Lagrange Interpolation

• Yet another way to make a smooth interpolating curve.
• In this approach, all data (control) points are interpolated with ONE function.
• A set of basis functions that will achieve this:
• (p.61, eqn 4.2)
• An important new concept: "knots" {here: t-values at control points}
• i.e., at what "time" do we pass the given points.
• Example of the Cubic Lagrange Basis with uniform knots (p.62) ...{20% down}
• Effect of changing the knot values
• experiment with applet (p.65) ... {40% down}
• squeezing "more" of  the curve between some knot pair --> yields bigger bulge.

### Lagrange Basis Functions Compared with Bernstein (p.62)

• Interpolation of ALL points
• NO tangent conditions
• Preserves affine invariance (transformation of control points)
• Preserves linear precision (collapse into a linear subspace)
• Maintains end-to-end symmetry, if knot intervals are also kept symmetrical.
• Convex hull does NOT apply (overshoots !)
• NOT variation diminishing
• look at a case with "extra wiggles" [(p.65) ... {40% down}]

### Evaluation of the Lagrange Curve

Again, direct evaluation is a bad idea! Problems with small values, division by zero.
• Iterated Linear Interpolation: Aitken Algorithm (skip for now; you probably will not use these curves for design tasks)