CS536 - Homework Assignment 2
Catmull-Rom Splines


Programming Problem:

Write a program, named CG_hw2, that evaluates a 3D Catmull-Rom spline and approximates it with a polyline.
Your program will read in an arbitrary number of 3D points, along with the tangents at the first and last points, and will fit a Catmull-Rom spline to them.
A Catmull-Rom spline is a C1 piecewise curve that consists of concatenated cubic Bezier curves.
Each individual Bezier curve is parameterized from 0 to 1. The curves' u parameters will be incremented by du during evaluation.
You should also add the "tension" property to your spline, as defined by Kochanek and Bartels.

CG_hw2 has the following specification:

  1. The program reads from a file two tangent vectors and the 3D points (3 floating point numbers) that will be interpolated by the spline, specified by the -f filename argument.
    The file will contain two tangent vectors followed by N 3D points, one per line, for example:
    dx1 dy1 dz1
    dx2 dy2 dz2
    x1 y1 z1
    x2 y2 z2
    x3 y3 z3
    x4 y4 z4
    ...
    Default value: cpts_in.txt
  2. The u increment (a real number between 0 and 1) is specified by the -u du argument. Default value: 0.09
  3. The tension value (a real number less than 1) is specified by the -t tension argument. Default value: 0
  4. The locations of the input points should be displayed with small spheres.
  5. The radius of the spheres is specified by the -r radius argument. Default value: 0.1
  6. Each cubic Bezier curve is parameterized from 0 to 1.
  7. Be sure to evaluate the individual curves only in the range 0 ≤ u ≤ 1, and that your spline interpolates all input points.
  8. Write the resulting graphics primitives in the Open Inventor format to standard out.
  9. Your program will be tested with the command "./CG_hw2 -f filename -u du -r radius -t tension > out.iv"
  10. Your program should not require arguments and should be able to process a subset of them in arbitrary order.

Example Output

The first two examples are the same two from HW1, but in Catmull-Rom (Hermite) form.

The following input data

   4 0 4
   4 0 -4
   0 0 0
   5 0 0

should produce this Catmull-Rom spline with
du = 0.025 (1/40), radius = 0.05, tension = 0, and this input file.

should produce this Catmull-Rom spline with
du = 0.025 (1/40), radius = 0.05, tension = 0.5.

should produce this Catmull-Rom spline with
du = 0.025 (1/40), radius = 0.05, tension = -0.5.

should produce this Catmull-Rom spline with
du = 0.089, radius = 0.1, tension = 0.

The following input data

   4 5 1
   3 1 2
   0 0 0
   5 0 0

should produce this Catmull-Rom spline with
du = 0.025 (1/40), radius = 0.05, tension = 0 and this input file.

The following input data

   3 -7 1
   2 3 -6
   -3.5 5.1 1.2
   -1.1 3.2 2.8
   0.5 7.3 3.5
   4.7 6.9 2.2

should produce this Catmull-Rom spline with
du = 0.0303 (1/33), radius = 0.1, tension = 0 and this input file.

The following input data

   3 -7 1
   6 9 -18
   -3.5 5.1 1.2
   -1.1 3.2 2.8
   0.5 7.3 3.5
   4.7 6.9 2.2
   5.5 -1.0 -3.8

should produce this Catmull-Rom spline with
du = 0.04 (1/25), radius = 0.1, tension = 0 and this input file.

The following input data

   3 -7 1
   6 9 -18
   -3.5 5.1 1.2
   1.1 3.2 -2.8
   0.5 7.3 3.5
   4.7 6.9 2.2
   6.5 1.0 -3.8
   3.9 4.7 -1.3
   6.9 -0.4 4.6
   7.8 -4.2 5.6
   9.6 2.7 -1.6

should produce this Catmull-Rom spline with
du = 0.02 (1/50), radius = 0.075, tension = 0 and this input file.

The following input data

   7 1 5
   -6 3 -10
   -3.5 5.1 1.2
   1.1 3.2 -2.8
   0.5 7.3 3.5
   4.7 6.9 2.2
   6.5 1.0 -3.8
   3.9 4.7 -1.3
   6.9 -0.4 4.6
   7.8 -4.2 5.6
   9.6 2.7 -1.6

should produce this Catmull-Rom spline with
du = 0.02 (1/50), radius = 0.075, tension = 0.

should produce this Catmull-Rom spline with
du = 0.02 (1/50), radius = 0.075, tension = 0.8.

should produce this Catmull-Rom spline with
du = 0.02 (1/50), radius = 0.075, tension = -2.

Grading Scheme

  1. Parsing input file correctly : 1 point
  2. Correctly display input points with spheres : 1 point
  3. Incrementing curve segments correctly : 1 point
  4. Implement tension correctly : 1 point
  5. Catmull-Rom spline evaluation correct : 6 points

4. Submission Guidelines:

  1. Assignments must be submitted via Bb Learn.
  2. Makefile whose default action is to create the executable, or include a script with the appropriate name.
  3. README file: explain the features of your program, language and OS used, compiler or interpreter used, name of file containing main(). Text files only. Word and PDF documents will NOT be accepted.
  4. All source code. Your code must compile and run on tux (Linux).
  5. You may program in any language you like as long it can produce a usable executable on tux.
  6. Your program will be run by the TA. Please do NOT submit any image files, Visual C++ project files, or anything not requested in this section. Your program must run on tux without the installation of "special" libraries.
  7. If you are using a language that doesn't produce an executable file, e.g. python, then be sure to include a script called CG_hw2 that accepts arguments and prints Inventor to standard out.
  8. Points will be deducted if submission guidelines are not followed.

NOTE: Your source code for all programming assignments will be run through a plagiarism detection system. This program uses compiler techniques which are invariant of syntax and style. If you are sharing code with other classmates, you will get caught. Please refer to the student handbook for actions that will be taken.


Last modified on October 11, 2018.