# CS 284: CAGD  Lecture #5 -- Mon 9/14, 2009.

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

## Preparation:

Rockwood: 59-73 (Lagrange Interpolation)

## Discussion of Homework Assignment:

What are good heuristics for the tangent directions and the two velocities ?

# 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
• Convex hull does NOT apply (overshoots !)
• Preserves linear precision
• NOT variation diminishing
• look at a case with "extra wiggles" [(p.65) ... {40% down}]
• Maintains end-to-end symmetry, if knot intervals are symmetrical, too.

### 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)
• The First Level of Interpolation
• Subsequent Level of Interpolation
• Geometric Interpretation and Generalization

## Circle Splines, Spiral Splines, Minimum-Variation Curves (MVC)

These are curves that are not subject to the "Linear-Precision Collapse"
Motivation: you want to obtain nice round loops with gradual change in curvature
-- E.g.: Always fit a circle through 3 control points;
-- For longer point sequences, fit multiple spiral segments.

"Fair, G2- and C2-Continuous Circle Splines," by C. H. Séquin, Kiha Lee, and Jane Yen.

"From Spiral to Spline: Optimal Techniques in Interactive Curve Design" Ph.D. thesis by Raph Levien (2009).

"Minimum Curvature Variation Curves, Networks, and Surfaces for Fair Free-Form Shape Design" Ph.D. thesis by Henry Moreton (1993).

# Sweeps Basics:

Needs a sweep path (open-ended or closed poly-line or spline curve);
Needs a cross section
(typically a polygon, but could be a poly-line or spline curve);
Needs specification how the cross section behaves as it is swept along the sweep path

(initial orientation: azimuth; possible twist along the way; perhaps torsion minimization).

Sweeps are an easy way to make water-tight surfaces and thus define the B-rep of a solid.
An amazing variety of shapes can be generated with just a few basic constructs !
Examples how I used sweeps:

## New Homework Assignment:

Smooth Sweeps along Complex 3D Curves

Study the sweep manual pages on SLIDE !

1. Implement smooth curve interpolation in 3D.
- - Start from the file http://www.cs.berkeley.edu/~sequin/CS284/CODE/pa2.slf
- - Write the corresponding formulae for the z-components of the inner Bezier control points.
- - Add the necessary z-expressions in all places where I have not already done so.
- - I have added a "Z-scale" slider that multiplies all the new z-coordinates with a slider-controlled constant,
so that you can readily go back and forth between 2D (multiplier=0.0) and 3D (multiplier=1.0).
- - Lift the data points out of the x-y-plane, and convince yourself that everything still "works smoothly."

2. Use the SLIDE "sweep" construct to form a small ribbon going along a closed B-spline curve approximating the original 15 control points.
- - This can be done by sweeping a "star" type cross section, and giving the star two skinny spokes.
- - I have already put in most of the needed code; if you turn on "drawSweep" in the "slf_swp" slider menu,
you should see such a ribbon in red, displayed edge-on.
- - However, the ribbon seems to have 10 pinched-off, twisted points in its loop; WHY is this ? -- Write down your thoughts.
- - Under what conditions do you get a nice "prismatic" sweep with no funny points ?
- - How do you have to set parameters such as : "minimizeTorsion" "closed (curve)" "symmetry" "azimuth" ...
in order to achieve a nice result ?   See manual pages on SLIDE !
- - Now lift the original control points out of the x-y-plane by increasing the "Z-scale" slider at the bottom of the "slf_bez" slider menu..
- - How is the behavior of the sweep different now ?
- - Pay particular attention to the end condition where the loop closes; under what circumstances do you get a smooth, seamless closure ?
- - Answer the same questions also for a 5-pointed star (set "Spokes" to 5).

ATTENTION: -- the "closed" flag does not seem to work when set dynamically:
closed {expr \$oSweep(closed)}
but will work when set explicitly in the SLIDE file, either as:
closed 0
or:
closed 1

Do this before WEDNESDAY, 9/16/2009 so you can ask questions and resolve issues for the remainder of this assignment.

3. Now try to make such a nice sweep along your own smooth, composite, interpolating curve.
- - It is somewhat tedious, since you have to specify a separate sweep construct for each of the 15 Bezier segments.
- - But again, the code is already in place, and you can see such a ribbon in green, if you turn on "drawSweep" in the "slf_bez" menu.
- - You may now want to turn off the B-spline at this time, so that you can focus on the Bezier segments.
- - For a 2D curve, as long as the ribbon is perpendicular to the curve's plane, everything should work fairly nicely.
- - But there may be problems in 3D. -- WHY ? What can you do about them ?
>>> Just discuss the issues you encounter in the 3D case. Find out what "hooks" are or are not available in the SLIDE sweep.
Briefly summarize what would have to be done to make nice prismatic sweeps along a composite Bezier curve in 3D,
and how the necessary information may be computed.
No need to actually do all the programming -- unless you want to.

4. Now use all the originally given points, as well as your own calculated control points,
to make a closed polyline with 45 joints, and then sweep a 5-pointed star along that polyline.
- - The code for this is right next to the B-spline "backbone" code (near line 467 in pa2.slf).
- - Under what conditions do you get nice prismatic beams with nicely mitered joints ?
- - How do you have to set parameters such as : "minimize Torsion" "closed (curve)" "symmetry" "azimuth" ...
in order to achieve a nice result ?
- - Can the "twist" parameter be of any use in achieving nice, properly mitred joints ? HOW ?
>>> Implement the sweep for the polyline case. The SLIDE machinery should handle all that.

DUE: Mon. 9/21/2009, 10:40pm.
Set the initial values for the sliders to the proper values, so that when your program is run,
one will see a nice "prismatic" sweep of a 3-pointed star along your best composite Bezier curve.
(You may want to change some of the parameters from the values that you gave them in pa1...)
>>> Without the implementation of (3), this will not work well in 3D.
But the 2D case is much simpler. You should be able to get nice results for the 2D case.

E-mail me a copy of your final modified pa2.slf SLIDE file.

Capture a hardcopy print-out of this sweep.

Hand in at the beginning of class:

• A hardcopy print-out of your sweep;
• and a page of text, answering the questions raised above.

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