# CS 284: CAGD  Lecture #3 -- Thu 8/30, 2012.

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

## Preparation:

Rockwood: pp 31-58.

## Working with Bézier Curves

• Derivatives
• Hodograph is just another Bezier curve;
• its control points have the coordiantes of the original connecting segments.
• Degree Elevation
• Choosing higher-order basis to obtain more control points:
• either to edit fine features into the curve,
• or to match the degrees of adjacent Bezier patches.
• The general formula for finding the new control points;
• think about redistributing the needed control points uniformaly along a straight line.

## Discussion of recent homework: What can you do with a single high-order Bézier Curve?

It is very difficult to design much curve details into the middle of the curve. To make visible wiggles, the control polygon must do extreme back and forth motions.
This is because the Bézier basis functions span the range of the whole curve segment; thus a lot of averaging out is going on.
If you compare this with the B-spline basis functions, you can see that those only have limited support; for the cubic case each hump only spans the range of four knots.
The mutual overlap of these basis functions still guarantees unconditional C2-continuity for cubic basis functions.
On the other hand, this implies that with a multi-segment B-spline curve one typically sees some extra "unused" control points at each end.
The domain over which the B-spline is defined
is somewhat shorter than the extent of the control polygon seem to imply (more later).

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

Options that we will discuss:
-- Stitching together Bézier curve segments:  ==> Requires careful adjustments of control points!
-- Hermite Splines:  ==> Almost like Bézier curves, but more explicit knowledge about derivatives at the ends.

-- Lagrange Interpolation:  ==> One continuous polynomial through all the given points; -- but danger of overshoots!.
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 degrees of freedom (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.

## New Homework Assignment: G1-Stitching of Bezier 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 hard part is to actually get SLIDE to load and to function properly on your computer. SLIDE is very particular about having all the paths set up properly, the variables in the right place, and using exactly the right version of Tcl. But it will be worth the effort, because we can then do many instructive experiements quite quickly. Good luck!

The first such experiment using SLIDE is to learn how to stitch cubic Bézier 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 Bézier segment, involving only information from the nearest neighbor points, and which guarantees a G1-continuous overall curve.

Information on how to install SLIDE on your computer can be found at:

The first file that you should try to run is:
http://www.cs.berkeley.edu/~sequin/CS284/CODE/icosa.slf
Make sure that you have in the same directory the files:  MATH.tcl,  MOVIE.tcl,  SLFCONSTS.tcl,  SLIDEUI.tcl
Then you may try other files in that same directory:  Instancing.slf,  IcosaGen.slf,  SweepDemol.slf,  GearMovie.slf

DUE: Tue Sept. 4, 2012:   Have SLIDE installed and the provided version of "pa1.slf" running.

For your first programming assignment, the code that you should modify and execute, can be found at:
http://www.cs.berkeley.edu/~sequin/CS284/CODE/pa1.slf

DUE: Thu Sept. 6, 2012:   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.

## Comments on SLIDE and Tcl

#### Basic SLIDE concepts:

• This is a single-assignment, declarative language.
• It builds scene hierarchies bottom-up:  defining vertices, poly-lines, splines, faces, cross sections, sweeps, spline patches, subdivision surfaces, offset surfaces ...
• Defined geometry can be re-used via instancing commands;
• these admit a variety of transformation operators: scale(), rotate(), translate(); these are applied in the order specified (in a top-down, world-view coordinate system).
• The rendering commands are mostly a set of "boiler-plate" commands that can be use with minimal modifications.

BRIEF  SLIDE DEMO . . .

#### Hints on SLIDE programming:

• Don't forget to load those Tcl files ( MATH.tcl,  SLFCONSTS.tcl,  SLIDEUI.tcl ) in the CODE directory into your working directory!
• To know what constructs are available, keep open the page:  http://www.cs.berkeley.edu/~ug/slide/docs/slide/spec/
• Start from a working program; don't try to write SLIDE files from scratch.
• Make small increments and try to run SLIDE after each small modification; this makes debugging easier.
• On Windows machines, Tcl crashes if it sees a syntax error, or encounters a variable that has not been properly defined;
therefore: make even smaller incremental changes when you modify Tcl code!  (The Mac version actually let's you see the error message).

## New Reading Assignment:

Rockwood: pp 59-73 (Lagrange Interpolation)

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