CPSC 441: Computer Graphics

Fall 2008


Assignment 6: Smooth Curves [60 points]

Due 12/7

Purpose:
This assignment will introduce you to methods for representing and manipulating smooth 2D curves. Extensions of the techniques you use in this assignment are used to represent surfaces for applications such as movies or industrial design.

Description:
In this assignment you will implement the three different algorithms we discussed for representing smooth curves: lagrange interpolation, bezier curves and b-splines. You should allow the user to add points by clicking the mouse on the screen. Once the user presses the 'e' key, no more control points may be added; however, the user should be able to select points on the screen and drag them around to modify the curves. When the user presses '1', you should display the curves defined by Lagrange interpolation. When the user presses '2', you should display the Bezier curves defined by the control points. Finally, '3' should display the B-spline curves defined by the control points.

For Lagrange interpolation, the user should be able to increase or decrease the degree of the interpolated curve by pressed '+' or '-' respectively. Start with a degree 1 curve. If the degree is currently d, then each consecutive set of d+1 control points should be interpreted as a single Lagrange curve. For example, if the current degree is 3 and the number of control points is 9, points 0-3 and 4-7 should be interpreted as two separate curves. Any extra control points should be ignored.

For Bezier curves your program should behave similar to Lagrange interpolation. '+' and '-' should increase or decrease the degree of the Bezier curves. The degree should be 1 to start with. Each set of d+1 control points hsould be interpreted as a single Bezier curve of degree d. Furthermore, if the user presses the 'i' key, you should find the intersection (if any) of the current Bezier curves on the screen and highlight the intersection with a point marking those locations. To determine the intersection between two Bezier curves, we discussed an algorithm based on the convex hull in class. You do not need to implement a convex hull computation. Instead, compute the axis-aligned bounding boxes of the two curves and their intersection to determine if you recur in the algorithm or not. If both control polygons can be approximated by a straight line (all control points within epsilon from the line defined by the first and last control point), then intersect the two lines.

Finally, for B-spline curves you should render a single B-spline curve of degree d. Again, the user should be able to control the degree of the curve using the '+', '-' keys.

You may cap the maximum degree of the curves at 8 and the minimum degree should be 1. Finally, you should create your own figure/image using one or more types of these curves of any degree greater than 1 that you wish. You do not need to allow the user to change the degree of the curves when displaying this image. However, you should display the control points used to construct the image. Points will be provided based on creativity.

Grading:
[5] Ability to add points with mouse click
[2] Correct transition ability from editing to point manipulation with the 'e' key
[5] Ability to modify the points by dragging them around on the screen and suitable display to indicate the positions of the control points on the screen
[2] Correct degree raising/lowering behavior for all three curves with '+'/'-' keys
[10] Correct display of Lagrange curves of all degree when user presses '1'
[10] Correct display of Bezier curves of all degree when user presses '2'
[10] Correct display of B-spline curves of all degree when user presses '3'
[10] Bezier intersection performed properly
[6] Creativity of your own figure created with these curves (user presses '4')