# CS 284: CAGD  Lecture #2 -- Tue 8/28, 2012.

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

## Preparation:

http://www.cs.berkeley.edu/%7Esequin/CS284/CAGD_LAB/CAGD_LAB.rar
You can also use the workstations in 349 Soda Hall. (Account forms handed out in class)

### Warm-up Question for the Day

• Draw the best curve through the given data!

### Discussion:

• What do we know about the data?
• Is the data noisy? Should the curve really go through all data points -- or just pass close by? -- How close?  - Do we know the error bars?
• What is known about the expected underlying shape of the curve?  - Is it just one smooth branch -- or is there some "fine structure" on top of it?

## How to Draw Interpolating (Smooth) Curves

• What is a Spline (physical, mathematical) ?
-- a piece of physical material, such as a furring strip or a vinyl hose.
-- a simple linearized approximation of the actual (energy-minimizing) physical shape.
• Interpolating spline; goes through the dots.
-- mostly used in design tasks with a sparse set of data points.
• Approximating spline; is "pulled towards" the dots.
-- mostly use in fitting to (noisy) data, e.g., from a scanner.

## Bézier Curves

• A very simple and very useful spline ...
• A mixture of interpolating (the two end points) and approximating (inner control points).
• The defining control points:  -- Quadratic case;  -- Cubic case.
• The general behavior
• Visualize properties with the applet in Ch3, (about 25% down).
• n-th degree case
•  How much can we do with a curve of a particular degree ? -- See homework assignment below!

### Bernstein Basis Functions

• Formulas: in book, page 35, eqn 38.  -- Symmetry in "t" and "(1-t)"
• Diagrams: check applet, page 36 (Ch3, 15% down); need to click on: "learn about Bernstein functions".
Basic Underlying Math;
• (Cubic) Polynomial: infinitely differentiable --> Continuity = C-infinity
• Cubic Hermite Spline: 2 endpoints, 2 tangent directions.
• Cubic Bezier Curve: 2 endpoints, 2 approximated intermediary control points.
•     -- (P1,P2) = 1/3 of starting velocity vector
•     -- (P3,P4) = 1/3 of ending velocity vector

### Understanding the Properties of Bézier Curves

• Endpoint Interpolation
• Look at basis functions; check cases for t=0 and t=1.
• Tangent Condition
• Look at the basis functions; differentiate.
• Convex Hull
• Partition of unity; only interpolation -- not extrapolation.
• Linear Precision
• Special case of convex hull property: Curve can collapse onto a line.
• Affine Invariance
• Splines are based on linear operators. A linear transformation (rotation, skewing, scaling) of the control points leads to a corresponding transformation of whole curve.
• Back-to-front Symmetry
• If control polygon is used in reverse order, the same shape results. (NOT true for some quaternion splines on sphere).
• Variation Diminishing
• Any line cannot intersect with the spline more often than with its control polygon.
• What can we say about the number of inflection points ?

### Drawing Bézier Curves:  de Casteljau Algorithm  ( "cass - tell - sho" )

• How NOT to evaluate a Bezier curve:
• by explicitely calculating a polynomial in the powers of t.
• Finding curve points by interpolation
• Recursive linear interpolation (p46).
• An efficient pipelining scheme, fast and robust!
• Finding Tangent Directions at various locations
• Use derivatives.
• Subdivision: Split curve at value t into two segments; find the control polygons for both segments.
• New control points come directly from de Casteljau algorithm.
• Use of subdivision for clipping to a boundary.
• Use of subdivision for curve refinement.

## New Homework: What can you do with Bézier Curves?

Use Rockwood's Interactive Curve Editor CAGD_LAB. Open the applet shown on page 52 of the book (Ch3, 70%down),
labelled "Higher Degree Bezier Curves" for the following tasks:
1. Using a septic (heptic) Bézier curve {this is degree 7, order 8; using 8 ctrl pts; ==> different ways of saying the same thing},
2. model G-1 continuous {continuous tangent directions} closed loops of as many different turning numbers as possible
{the # of times the tangent vector sweep around 360 degrees}  -- Do it at least for turning numbers 0, 1, 2.
3. Using the minimum number of control points (= minimum order Bezier), make a G1-continuous "figure-8" Bezier curve with overall C2-point-symmetry
{= 2-fold rotational symmetry around a point that will bring the figure back onto itself after a 180-degree rotation around this point}.
DUE: THU 8/30/12, 2:40pm.
Hand in: window snapshots showing your solutions;
label your figures with their turning numbers;

On the PCs you can hit Alt+PrnScrn to capture the current active window to the clipboard.
You can then paste the clipboard into a program such as "paint" and from there readily send it to the printer.

### Quick Review of Some Important Concepts

• Hodograph:
-- plot of parameterized derivative vector in its own coordinate system.
-- if hodograph goes through origin, curve velocity goes to zero; this often leads to a cusp.
-- Control polygon for hodograph of a Bézier curve.
• Winding Number of a (closed, oriented) Curve around a Point:
-- how many times does it loop around that point ?
-- a crucial quantity to determine the "inside" of self-intersecting polygons.
-- only curves with the same winding number can be smoothly transformed into one another in the plane.
• Turning Number of a (closed) Curve:
-- counts the (signed) number of turns made by the tangent vector of the curve.
-- if v<>0 it is equal to the winding number of hodograph around the origin.
• Cn Parametric Continuity:
-- first n derivatives are continuous; curve is n-th order differentiable,
-- but the curve may still have cusps where v=0.
• Gn Geometric Continuity:
-- is determined entirely by the visual appearance of the shape of the curve (ignoring parametrization).
-- first n-order geometric approximations (tangent, curvature, ...) vary smoothly with arclength.