Math 155B – Topics in Computer Graphics – Spring 2019
 

Project #1 - Catmull-Rom, Overhauser, and Centripetal interpolating splines

Overview:  For this assignment, you will write a program that accepts points via mouse clicks, and draws a spline curve that interpolates them.  Your program will generate three kinds of curves: Catmull-Rom curves and Overhauser curves with chord length parameterization and with centripetal parameterization.. 

Due date: Friday, April 12, 9:00pm.

Download a sample executable from:

http://www.math.ucsd.edu/~sbuss/CourseWeb/Math155B_2019Spring/Project_1/ConnectDotsDemo_Spring2019.zip

Download starter code from ConnectDotsModern program on the book’s software web page. The direct URL is:

http://www.math.ucsd.edu/~sbuss/MathCG2/OpenGLsoft/ConnectDotsModern

Your program should support the following: (Test them out with the executable downloaded in the zip file above).

  1. Left mouse button is used to place points in the window.  The curve is updated on the screen interactively with mouse clicks.
  2. The curve interpolates all the points, including the first and last points.   This was not true of the Catmull-Rom and Overhauser splines as defined in class.  You may implement this in several ways.  The most likely ways are either: (a) by acting as if the first and last point are placed twice or (b) by setting the first derivative to zero at the beginning and the end of the curve. (The “Demo” program uses the first option, but the second option is perhaps better.  Either way is OK for your programming assignment.)
  3. The 0 command shows straight-line interpolation;
  4. The 1 command selects Catmull Rom curves (unit length parameterization);
  5. The 2 command selects Overhauser curves with chord length parameterization;
  6. The 3 command selects Overhauser curves with centripetal parameterization.
  7. The f (F) command removes the first point on the curve.  The l (L) command removes the last point on the curve ("f" for "first" and "l" for "last").  If more than 100 points are placed, then the first point is removed when a new point is added to the end. This is already implemented in the ConnectDotsModern program.
  8. (Optional.) The command c (C) (for “control polygon”) toggles drawing of the control polygon. This is not a required element of the programming assignment, but it is recommended to implement it to help with debugging.
  9. Selecting a point by right clicking with the mouse, and holding the mouse button down, allows you to drag an interpolation point to a new position. This is already implemented in the supplied ConnectDotsModern software: your program only needs to update the interpolating curve when this happens.
  10. BONUS TASK: If you find all of the above is implemented easily, this is a bonus feature: Design and implement a method to add interpolation points in the middle of the curve. For instance, by shift-right-clicking on the curve.  (This is worth up to 1 point (out of a total of 20) for your programming assignment score.)

A starter version of the program is available online from http://math.ucsd.edu/~sbuss/MathCG2/OpenGLsoft/ConnectDotsModern.   This program supports catching mouse clicks, straightline interpolation, the and l commands, clamping to at most 100 points, and dragging vertices.  It draws only straight-line segments, not curves:  your main job is to add to the program the ability to draw interpolating curves (Catmull-Rom and two kinds of Overhauser splines).  
    The sample program draws big, black points and thick, colored lines and curves.   

Helpful hints:

  1. Start with the provided ConnectDotsModern code.
  2. For each segment of the curve, compute the Bezier curve control points for that segment.  This will give you a total of 3*(NumDots-1)+1 many points.  Store these in a separate array. If your program also displays the control polygons of all the Bezier sub-curves, you will need to also store these is a separate VAO/VBO.
    - Step 2 is performed differently for Catmull Rom, chord-length Overhauser and centripetal Overhauser, since they calculate the control points for the Bezier subcurves differently, but the rest of the steps can be the same for all three types of curves.
  3. Then, for each Bezier subcurve of the curve, calculate sufficiently many points on the curve, store them into an array, and then load them into a VBO.  You should use the DeCasteljau algorithm to evaluate the curves.
    You are recommended to use a separate VAO and VBO for drawing the curve as a sequence of short line segments.  Introduce a parameter (suggestion: call it “MeshRes”) for the number of straight-line segments used to approximate each Bezier curve; experiment to find out what values work well (say between 20 and 40).
  4. Since there is a known upper bound on the number of interpolation points, you can preallocate arrays to hold all your data: you do not need to dynamically allocate arrays.
  5. Your points are points in 2-space. You can either store them as a arrays with separate x- and y- coordinates. But it is likely to be better use the VectorR2 class (available from the textbook’s course web page in LinearMapR2.h) to handle 2-vectors directly.  (Alternately, find another 2-vector C++ class to use, or write your own…)
  6. Watch out for repeated points (obtained by clicking the same point twice in a row), so you do not get a divide-by-zero exception.  Handle repeated points as you think best. Be prepared to explain how you handled this.

Hand in procedure:   FIRST: As usual, make sure your code compiles and runs under Visual Studio on the computer lab systems. In-person grading will use these systems. Please do not modify your files after the due date without letting us know first.

SECOND: Upload your primary source file(s) to gradescope.

Grading:  Grading is an individual session with Nick Sieger or Professor Buss.   You should be prepared to explain how your program works, and to show examples of the relative advantages and disadvantages of the Catmull-Rom splines and the two types of Overhauser splines.