Bezier Curves and Surfaces
Due 6 April 2017
For this assignment you'll implement Bezier curves and surfaces as part of the hierarchical modeling system.
Tasks
Bezier curves and surfaces are useful general-purpose modeling tools. This week you will add them to your graphics system. The Graphics Specification includes the updated functions. There is a new section on Bezier curves, and there are new module functions.
The major steps are outlined below.
- Create a Bezier Curve data type, as well as the functions to set the Bezier Curve control points from a list of four Points.
-
Create a function bezierCurve_draw that draws a Bezier Curve into
the image. This function assumes the control points are in screen
coordinates. You can choose how to do this, but the easiest method
is to subdivide the curve using the de Casteljau algorithm until
the control points are close enough together that you can draw
short lines between them to approximate the curve. The pretty way
to do this is to use recursion.
- If the maximum dimension of a bounding box around the control points is less than a threshold (e.g. 10 pixels), draw the three line segments between the four control points and return.
- Otherwise, use the de Casteljau algorithm to divide the Bezier Curve into two new curves, each with four control points, and recursively call the draw function on each of the halves.
You can use this test function to create the picture below, which was created using a bounding box threshold of 10 pixels on the maximum dimension.
-
Create a function module_bezierCurve that adds a Bezier curve to
the current module with the given degree of subdivision. If the
subdivision value is 0, the function should add the three line
segments connecting the four control points to the module. If the
subdivision value is not 0, then the function should execute that
number of subdivisions of the curve, using the de Casteljau
algorithm, before adding the lines to the module. Note, you do
not have to change your module_draw function, as you are adding
only lines to the module. You can do this recursively.
You can use this test function to create the animation sequence below. The function takes in a command line argument that is the number of subdivisions. The animations below show 0, 2, and 4 levels of subdivision.



-
Create the bezierSurface_set function. We'll use a 4x4 grid of
points to define a 3rd order surface. Then create the function
module_bezierSurface, which takes in both a level of subdivision
and whether to make the surface a wire frame (lines) or a solid
surface (polygons). Only the wire frame functionality is required
for this project.
You can use this test function to create the animation sequence below. The function takes in a command line argument that is the number of subdivisions. The animations below show 0, 1, and 3 levels of subdivision.



- Create a function module_cylinder, that adds a unit cylinder to the current module. This should not take too long, as you can look at the prior assignment for an example of this function. Attribute it in your code if you borrow it. Make sure the function can be parameterized by the number of subdivisions for the cylinder.
- Create two more functions that make some kind of useful 3D primitive, such as a pyramid, a tetrahedron, an octahedron, or a sphere. If you really want to go for it, make a dodecahedron.
- Make two creative images that include bezier curves or surfaces.
Extensions
-
Make a teapot. You can find the Bezier curves for the teapot
here.
- Make more modeling primitives.
- Implement polygons for the surface. Make triangles.
- Implement some other type of spline.
- Make more creative images (i.e. more than the required two).
- Implement some physics within an animation.
- Implement Liang-Barsky/Cyrus-Beck clipping in your line drawing algorithm.
Writeup
Make a wiki page and give it the label cs351s17project7. Put up your required and portfolio images along with brief descriptions and relevant information.
Handin
Put your code on the handin server in a project 7 directory in your Private folder.
Spring 2017