Computer Science 4160 - Computer Graphics
Assignment 2
Fall 2005
Curves - Bezier Curves and B-Splines
Due Oct 7, 11:59pm
In this assignment you will use the De Casteljau Algorithm, and variations of it, to draw Bezier curves and B-Splines. You will also be asked to implement a rendering of Bezier curves using recursion. The most helpful information will be found in the lecture material.
Post any questions you have to the newsgroup. USE DETAILED SUBJECT HEADINGS . Other students will want to see the answers too. Do not post anything resembling code.
/* YOUR CODE HERE */.
This assignment uses the mouse much more than the keyboard. Part of your task is to look at the code to figure out how to use the program.
You will want to complete WorkingScene before anything else. Once you have done this correctly, you will be able to draw regular Curve (just straight lines) by LEFT clicking on the screen to add points. You should be able to delete points by RIGHT clicking in them. You can also drag existing points around.
RULES FOR YOUR CODE:
Helpful functions
The class Curve has the function drawLine( ), which you should use to draw straight lines.
The class Point has a function draw( ). For drawing knots in the B-Spline, you will want to create a point, and ask it to draw itself.
This assignment uses the <vector> class from Standard Template Library (STL). It is a very powerful class, but may have a slight learning curve. It is worth investing the time to learn how to use this. Microsoft's MSDN web site is a good source of information. There are also plenty of books and other web sites that discuss STL. If you really don't want to use <vector>, figure out just enough to convert the vector of points into a form your comfortable with before you start your manipulations of the points.For Bezier2, you are provided with a more complete skeleton. This code uses <vector>. You may choose to rewrite draw(), but we reccomend that you study this code and fill in the provided structure. This will help you learn the <vector>, as well as the recursive algorithm for Beziers.
Clarifications
Some students have expressed confusion at the difference between
Bezier and Bezier2. For Bezier, you simply divide the curve into line
segments (depending on the detail parameter, there should be detail
segments). Hence, all you need to do is evaluate the curve at
detail+1 points, connecting these with line segments. The evaluation
can be done by the deCasteljau algorithm as described in class, or you
can use the explicit Bernstein-Bezier polynomial form. For Bezier2,
you draw the curve by recursive subdivision, splitting it at its
midpoint each time. The recursive subdivision of Bezier curves using
the deCasteljau algorithm was discussed in class. Finally, for
drawing cubic B-splines, you can either use a variant of the
deCasteljau algorithm, or the B-spline matrix formula discussed in
class directly. This latter formula applies since the knot spacing is
uniform and the B-splines are always cubic.
Hints and Documentation
We briefly provide some brief hints and documentation that may be helpful.