# Workbook 5: Curves in 2D

## CS559 Spring 2021 Sample Solution - Workbook 5

Written by CS559 course staff

You can try out the example solutions here. The interesting code is on page 9, page 11 and page 12.

This workbook is due on Monday, March 1, 2021.

In this workbook, we’ll get beyond straight lines to consider curves in 2D.

The “programming project” that goes with Curves is to make a train. Originally, we had the train as part of this workbook - but it was too much for one week (the train is a pretty big thing unto itself). So, this workbook covers the basics of curves, and then next week you’ll use some of it to make the train.

Several pages have required exercises on them. But, as always, feel free to tinker with all of the provided example demos.

## Learning Goals

1. To understand the concepts of parametric curves and parameterizations
2. To understand curve tangents, derivatives, and continuity conditions
3. To understand piecewise polynomial representations of curves
4. To understand cubic segments, and the need for different forms
5. To understand arc-length parameterizations and how we approximate it
6. To understand the ideas and properties of Bezier curves including their geometric and algebraic formulations
7. To understand how we draw curves, including adaptation
8. To be able to use curves in various APIs, including curve format conversion

Note: you will want to mix the required reading, the optional reading, and the workbook together.

Textbook: Curves are covered in FCG4_Ch15.pdf (0.5mb). Since this chapter is a little mathematical, mix the reading with the lectures and the workbook to connect the intuitions. Hart20-jan19.pdf (2.4mb) is optional, as it covers much of the same material in a different way. We won’t cover all the material in class. The required sections are:

1. FCG 15.1 - basic ideas of curves, including parameterizations and piecewise representations
2. FCG 15.2 - curve properties (especially continuity)
3. FCG 15.3 - polynomial pieces - you need to have the basic intuitions, however, you will not need to do the derivations yourself.
4. FCG 15.4 - putting pieces together - this makes things sound more complicated than they are
5. FCG 15.5 - cubics - again, you won’t have to derive the different cubic types, but make sure you know what hermites and cardinals are
6. FCG 15.6.1 - Bézier curves - very important, since they are what gets used in Canvas and many other things. The workbook and lectures will give you the intuitions, the book will show you the equations.

In Hart, you should read this to clarify and reinforce the required material above, but there isn’t anything new, so this can be considered optional.

1. Hart 20.0 - basics of curves, a good review of the terms discussed in FCG 15.1-15.3
2. Hart 20.1 - the wiggle theorem - make sure you have the intuition that an nth degree polynomial has n-1 wiggles.
3. Hart 20.2 - Lagrangian curves - this is also 15.3.6 in FCG - understand the basic idea to know why we don’t use these things.
4. Hart 20.3 - Hermite curves - these are in 15.3.4 and 15.5.2 of FCG. You won’t need to derive them, but understanding what they are will be useful for Beziers and Cardinals, which we will use a lot.
5. Hart 20.4 - Bézier curves - these are important, so seeing them more than once may help.

The rest of the Chapter focuses on B-Splines and rational curves, which we won’t cover in class.

Videos: A few years ago, we made some videos to explain the algorithms for Bezier curves (they are optional but helpful):

• DeCastlejau 2 - Showing the algorithm for 3 points (a second degree curve)
• DeCastlejau 3 - Showing the algorithm for 4 points (a third degree curve)
• DeCastlejau 4 - Shows the connection between the geometric constructions and the polynomial forms

Note: there aren’t many bonus points this week. Next week, there will be many bonus point opportunities.

Workbook Rubric (92 points total)
Points (87):
8 pt
correct turn in
Box 05-01-02
4 pt
implement the correct tangent vector for the parabola
Box 05-03-01
4 pt
cubic coefficients question
Box 05-04-01
2 pt
evaluate Hermite
Box 05-07-03
9 pt
divide the Bezier curve
Box 05-09-01
5 pt
recreated the picture using canvas
Box 05-09-01
5 pt
Box 05-09-02
10 pt
draw a picture that demonstrate the use of bezierCurveTo in Canvas
Box 05-09-02
4 pt
explained where there is G(1) continuity
Box 05-10-03
10 pt
make the green dot go around the triangle with arc-length parameterization
Box 05-11-01
10 pt
draw the spiral
Box 05-11-01
3 pt
checkbox control of lines
Box 05-11-01
3 pt
slider control of points
Box 05-12-01
10 pt
correctly use UI code
Bonus points (5):
Box 05-09-02
2 pt
artistic merit for making a cool picture
Box 05-11-01
3 pt
approximate spiral with Beziers, have a switch for lines/Beziers

As you go through the workbook pages, feel free to tinker with the programs we have given you as a way to understand how they work!

## Get Started

Don’t forget to commit and push as you work!