# Workbook 6: The Train (More Curves)

## CS559 Spring 2021 Sample Solution - Workbook 6

Written by CS559 course staff

You can try out the example solutions here. The interesting code is on page 3.

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

## Learning Goals

1. To review the key concepts of parametric curves.
2. To practice some key computations with curves.
3. To implement various aspects of curves in the context of an application.
4. To appreciate why curve concepts, such as arc length parameterization and smoothness, are useful.
5. To write an interesting graphics program.

This workbook continues our study of curves in 2D. Last week’s workbook went through the key ideas. This week, we’ll put those ideas into action in a programming assignment: making a train that goes around a track.

This workbook builds on the previous workbook; the first pages will give you some extra practice with the concepts.

There is no new required reading for this week. The readings on curves were part of Workbook 5. You may want to review these readings (including the workbook itself). If you haven’t read them, now is a good time to do it. Doing the train will require you to understand the key concepts of curves. Some curve topics are less important for the train, but will come back on exams, or, if you ever do something in computer graphics beyond class.

Textbook: Curves are covered in FCG4_Ch15.pdf (0.5mb). We won’t cover all the material in class. The 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 - you’ll need cardinals for the train
6. FCG 15.6.1 - Bézier curves - very important, since they are what gets used in Canvas and many other things.
7. FCG 15.6.2 - B-Spline curves - (and 15.6.3 and 15.6.4 which are advanced kinds of B-Spline curves) is optional.

Hart20-jan19.pdf (2.4mb) covers much of the same material in a different way. You should read this to clarify and reinforce the required material above.

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 (at most) 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.

Workbook Rubric (105 points total)
Points (85):
Box 06-01-01
10 pt
Make a cardinal spline through the points
Box 06-01-02
10 pt
Split the Bezier
Box 06-03-01
15 pt
Drawing the track as a simple curve (cardinal spline) that interpolates the control points
Box 06-03-01
15 pt
Train goes around the track
Box 06-03-01
10 pt
The interface still works (the track can be moved and the run slider works, even while the train is in motion)
Box 06-03-01
5 pt
Train has a front
Box 06-03-01
10 pt
Train points in the right direction as it goes around the track
Box 06-03-01
5 pt
Track configuration shows off arc length (train should speed up and slow down if arc length parameterization is turned off)
Box 06-03-01
5 pt
Text file explains features
Bonus points (29 possible, of which you can earn a maximum of 20):
Box 06-03-01
5 pt
Arc Length parameterization (train goes at a relatively constant speed as it goes around the track, no matter what the control point spacing is). You must add a checkbox to turn this on and off. This one is hard, but it enables several of the other things, so it is actually worth a lot
Box 06-03-01
2 pt
Rail Ties drawn perpendicular to track
Box 06-03-01
2 pt
Rail Ties drawn with correct spacing (this is simple once you have arc-length
Box 06-03-01
3 pt
Parallel rails
Box 06-03-01
5 pt
Multiple cars (requires keeping the cars a fixed distance apart)
Box 06-03-01
3 pt
Trucked wheels (requires keeping the pairs of wheels the correct distance apart and on the track, and having the train car positioned appropriately - this is only for people who are into trains and appreciate this detail)
Box 06-03-01
1 pt
Slider to control tension
Box 06-03-01
2 pt
Switchable B-Splines
Box 06-03-01
2 pt
Smoke
Box 06-03-01
1 pt
Scenery
Box 06-03-01
1 pt