# CS 284: CAGD  Lecture #4 -- Wed 9/09, 2009.

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

## Preparation:

Rockwood: 59-73 (Lagrange Interpolation)

# Main Lecture Topic:

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

Options that we will discuss:
-- stiching together Bézier curve segments;
-- Hermite Splines;
-- Lagrange Interpolation.

All these splines are polynomial based; all of them are invariant under affine transformations,
thus for all of them each coordinate component can be dealt with individually.
All of these spline types have some unconstrained DoFs 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) -- NOT part of your assignment!
• 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

Don't forget to load those TCL files in the CODE directory into your working directory!

BRIEF  DEMO . . .

SLIDE will be set up in 330 Soda on the 6 machine on the wall opposite the entry doors.
The door of 330 is open during the day; in the eveing your key card should give you access if you are enrolled in a CS course.
You need an account to use these machines. I can expedite this if you send me your e-mail and your student ID,
which I will then forward to the EECS Instructional Support Group.

## (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.

## New Homework Assignment: G1-Stitching of Bezier Curves

Assuming that you have been able to install SLIDE on your computers,

your first experiment using SLIDE 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.

For your first programming assignment, the code that you should modify and execute, can be found at:

DUE: Wed Sept. 14, 2009:   Have your modification of "pa1.slf" running. 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/observations you would like to make.

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