# CS 284: CAGD  Lecture #4 -- Th 9/07, 2006.

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

## Preparation:

Read:  RC pp 59-73.

# Main Lecture Topic:

## How to make interesting, complex, smooth curves that interpolate given points.

Last lecture: How to use Bézier curve segments, properly stitched together, to make an interpolating spline.
This lecture: Other approaches: Hermite Splines; Lagrange Interpolation.
All types of splines thus far, are polynomial based; all of them are invariant under affine transformations,
thus for all of them each coordinate component can be dealt with individually.
For a given curve interpolation problem, all of these spline types have some unconstrained DoF that can be used for optimization.

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

• Remember Experiment from Lecture #1: (closed) interpolating curve through N (2D) points.
• Counting Degrees of Freedom (DoF)
• Each control point in 2D has 2 DoF.
• Each constraint imposed removes one DoF.
• How many DoF are remaining ?
• (3N for G1;  or 2N for G2;  or 2N for C1).
• How to use these DoF's ?
• Optimize the curve !
• Make it as pleasing as possible: --> See Programming Assignment #1.
• Find a good automated heuristic to place the extra control points.
• Global Optimization (approximation)
• Define a cost function:
• E.g., Bending Energy = arc-length integral of square of curvature.
• (Approximate this as best possible with Bezier segments).
• How would you do this ?
• Find out how each DoF affects the total Energy (e.g., by doing finite differences),
• All these components form an overall gradient vector in 3N space,
• Move along gradient vector towards local minumum in energy.
• A specific example: Make a "pleasing" (low bending energy) figure 8 curves from just two cubic Bezier segments.
• How to set up the first guess ?
• How many DoF?
• First looks like 2 ... one for shape and one for scale ...
• but there may be a scaling instability for MECs (minimum energy curves)!
• How to use them ...
• Evaluate the energy for some values of this angle,
• do a binary search for minimum.
• Advanced approaches to optimization ... later!

## Comments on SLIDE and Tcl -- Q&A

Also load those TCL files in the CODE directory!

## (Cubic) Hermite Splines

• Another - practical - way of making interpolating curves.
• Review Basis Functions (page 70)
• If all direction vectors are given at all points,
• -- job is done ... just like connected 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 B+B+B "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, velocity, acceleration(curvature) at each joint.
• To make "good-looking" C2-continuous interpolating curves, use some heuristic to set those values based on "local" information.

## Preview of Lagrange Interpolation

• Another way to make a smooth interpolating curve.
• The goal: To interpolate all data (control) points with ONE function.
• A set of basis functions that will achieve this (p.61, eqn 4.2)
• The concept of "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.
• Effect of changing the knot values: Squeezing "more" of the curve between some knot pair --> yields bigger bulge.

## Current Homework Assignment: G1-Stitching of Bézier Curves

In this first programming assignment you will be introduced (gently) to SLIDE and to the Tcl language. Your actual programming will be less than ten lines of code (most of the expressions you will need have already been provided), but it encourages experimentation and thinking.

The goal is to learn how to stitch cubic Bezier segments together to make a smooth, pleasing-looking, interpolating curve that behaves well even for rather ragged control polygons with irregularly spaced control points (like the example we did in class by hand).

Your assignment is to find a robust expression for the placement for the inner control points of each Bezier segment, involving only information from the nearest neighbor points, and which guarantees a G1-continuous overall curve.

DUE: Sept. 12, 2006, 2:10pm. -- Hand in:

• Window snapshot showing your best solution;
• The formula you used to place the inner control points;
• A one paragraph discussion of your approach, and what you learned from it;
• any other comments you would like to make.

The code that you should modify and execute, can be found at:
http://www.cs.berkeley.edu/~sequin/CS284/CODE/pa1.slf

Also copy the TCL files:  MATH.tcl, SLFCONSTS.tcl,  SLIDEUI.tcl  to the directory in which your run your SLIDE file.

Information on how to install SLIDE on your computer can be found at:
http://www.cs.berkeley.edu/~ug/slide/viewer/slide2004/README

## Reading Assignment:

Read again:  RC pp 59-73  and  pp 93-97; 108-112 (preview of B-Splines)

PREVIOUS < - - - - > CS 284 HOME < - - - - > CURRENT < - - - - > NEXT
Page Editor: Carlo H. Séquin