CS155

Parametric Curves



In this lab you'll develop code to compute and draw a Catmull-Rom spline and a Bezier curve. Start by downloading the sample executable catmullRom.exe. When you run the program, you'll find 4 control points and their associated curve. You can move the "current" control point, which is highlighted in white, by using the x,X,y,Y,z, and Z keys. You can change the "current" control point by using the n and N keys. The "h" key explains key controls. You can change the camera position using the mouse.

You are going to create your own version of this program. Download the starting code here. Create a new visual studio project then build and run the executable.

You need to complete the drawCurve() function to

  1. Compute the coeffecients of the Catmull-Rom cubic polynomials X(t), Y(t), and Z(t).
  2. Sample the polynomials in order to draw a line strip that approximates the curve.
After you get 4 control points working, change the number of control points by changing the variable numPoints to 8. (Note: Adjacent curves will share 3 control points. The only additional changes you'll need to make are in the code you've already written.)

Finally, implement a Bezier curve modeler. Use as much code from your catmull-rom modeler as you can. Start with 4 control points then extend to 7 (2 curves) with C1 continuity. (Note: When the user moves particular control points you will have to move a second as well to ensure C1 continuity.)

Save your work. You will use your Bezier modeler as the basis for the next lab on picking.