# CS 559 Programming Assignment 4 solution

\$30.00

Category:

## Description

Description
In the last few lectures we discussed the representation and implementation of parametric
curves, including certain types of cubic curves with convenient properties. We addressed the
motivation in using such geometric tools (e.g. creating more intricate shapes than the ones
allowed by built-in canvas commands, and having the ability to animate objects along them).
We also looked at implementation considerations associated with the use of parametric
curves in 2D (most of which are found in our GitHub repository
(https://github.com/sifakis/CS559F22_Demos) under Week5/), such as the drawing of a curve as
a finely-refined chain of line segments [JSBin demo] (http://jsbin.com/ziletiq) , using the
parametric representation to control the position and orientation of an object that travels
along the curve [JSBin demo] (http://jsbin.com/meliyax) , and how piecewise-defined curves
are implemented and what different degrees of continuity feel like [JSBin demo]
(http://jsbin.com/vupevab) . In Week 6, we also talked about various types of cubic polynomial
curves (including Hermite and B-Splines; we will also talk about Bezier curves in Week 7),
and the convenient properties they provide as building blocks of composite (piecewise-cubic)
curves (see our GitHub repository (https://github.com/sifakis/CS559F22_Demos)
under Week6/).
In this assignment you will create your own program, in the spirit of the demos we saw in
class, extending them of course into something more interesting and hopefully exciting! You
are welcome to take inspiration or even adopt some of the implementation practices from the
in-class demos; your program, however must fulfill the following requirements in order to get
CS 559 Programming Assignment 4
Requirement #1. Your drawing has to include, at minimum, one of the following:
(a) A piecewise-defined curve, that shifts from one formula to another (see the example in
this [JSBin demo] (http://jsbin.com/vupevab) ), that is also closed in the sense that the
curve returns to the place where it started, forming a closed “loop”; note that this is
different from the example we saw in class, where all curves, including those that had
piecewise-definitions, were “open”.
or (you can do both if you wish!)
(b) Multiple separate curves, out of which one has to have a piecewise-defined formula
(i.e. at least two components with different formulas, joined together), but in this case the
curves don’t have to be closed (unless you want them to be!).
Requirement #2. Your drawing needs to have at least one object that is animated using
one of the curves defined. It is sufficient to have the parametric curve control only
the position of the moving object (as in this [JSBin demo] (http://jsbin.com/ziletiq) ), but if
you want to be extra fancy you can also control the orientation of the moving object (see
this [JSBin demo] (http://jsbin.com/meliyax) ).
Requirement #3. You must “draw” the path of at least one of the curves involved in your
scene (consider the way we discussed in our demos, by splitting the curve up into small
line segments). It’s ok to have a “switch” of sorts (e.g. the value of a slider) that “turns off”
drawing the curve line, if you feel your scene looks better without it! As long as there is
the option to display that path, you are good!
Requirement #4. At the point where the different formulas of a piecewise-defined curve
in your scene, you must enforce at least C0-continuity (G1-continuity or higher would be
nice; C2 might be overkill, but you are welcome to do it). This is just for one of the
junctions in one of your piecewise-defined curves; you are free to use any degree of
continuity for all other cases.
Requirement #5. At least one of the curves you use in your implementation has to be a
parametric cubic (Hermite, B-spline, etc or even Bezier if you read about it from FCG
Chapter 15, or catch the in-class description on Oct 18th). It doesn’t have to be the case
that all components of a piecewise curve will have to be a cubic … just that somewhere in
your scene there must be a curve that has at least one component (if it’s a
piecewise/component curve) that’s a cubic. Frankly, you might find that one of the most
natural ways to enforce C1 continuity (if you choose to have at least that degree of
smoothness) is to resort to cubics anyhow …
You are welcome to use either sliders, or automatic animation to “move” your objects along
any curve trajectories; use whatever feels best for your vision of the scene you want to
CS 559 Programming Assignment 4
create!
As always, you are encouraged to try and exceed these requirements, and if you do well,
you can compete for a “4” above-and-beyond grade. Here are some recommendations for
that (do several of these to be more competitive):
Controlling position and orientation of objects in your scene.
Having controls/sliders that alter the shape of your curved trajectories.
Create intriguing motions and shapes.
Enhance the appearance of curved profiles by giving them “thickness” or drawing multiple
parallel lines that go alongside your curve; think of a train track with 2 parallel rails, that
swerve together!
Have multiple moving objects in curve trajectories that somehow interact … a race-track
with multiple cars for example, sometimes overtaking each other?