CS536 - Assignment 4
Surface of Revolution


Programming Problem:

Write a program, named CG_hw4, that evaluates a surface of revolution and approximates it with triangles.
The surface is defined by a Catmull-Rom spline lying in the X-Z plane, which is rotated around the Z axis.
Use a tension value of 0 for the C-R spline.
Your program should be able to output both a flat-shaded and smooth-shaded polygonal approximation of the surface.
The patch's u and θ parameters will be incremented by du (1/(num_u-1)) and dθ (1/(num_t-1)) during evaluation.

CG_hw4 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 C-R 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: rev_surf_in0.txt
  2. The u increment (du, a real number between 0 and 1), can be computed from the number of points computed for each Bezier curve specified by the -u num_u argument. du = 1/(num_u-1). Default value: 12
  3. The θ increment (, a real number between 0 and 2π), is determined by the -t num_t argument. num_t is a positive integer which defines the number of samples of the θ parameter. dθ = 1/(num_t-1). Default value: 22.
  4. The argument -F tells your program to output a flat-shaded (no normals) triangle mesh.
  5. The argument -S tells your program to output a smooth-shaded (with normals) triangle mesh.
    You should compute the exact normals and not an approximation derived from the mesh.
    If neither the -F or the -S argument is given, a flat-shaded mesh is written to the output.
  6. In your README file, list the filename and line numbers of the code that implements your surface normal calculations.
  7. Write the resulting graphics primitives in the Open Inventor format to standard out.
  8. Your program will be tested with a command like "./CG_hw4 -u 22 -f filename -t 33 > out.iv"
  9. Extra Credit: Cap off your surface with a triangle fan, so the open surface becomes a solid. Add cap with -C option. The cap triangles should not be smooth-shaded/blended with the original surface.
    Add a note to your README file that states if you have or have not implemented this feature.
  10. Your program should not require arguments and should be able to process a subset of them in arbitrary order.

Here are two example input files that can be used for testing.
rev_surf_in0.txt     rev_surf_in1.txt
Note that all of the y components are zero.

Output for the command "./CG_hw4 > rev_surf_out0.iv" is here

Output for the command "./CG_hw4 -S > rev_surf_out1.iv" is here

Output for the command "./CG_hw4 -f rev_surf_in1.txt > rev_surf_out2.iv" is here

Output for the command "./CG_hw4 -f rev_surf_in1.txt -S > rev_surf_out3.iv" is here

Grading Scheme

  1. Evaluate Catmull-Rom spline correctly: 1 point
  2. Incrementing parameter values correctly : 2 point
  3. Evaluate surface points correctly : 3 points
  4. Evaluate surface normals/smooth-shading correctly : 4 points
  5. Add surface caps : 2 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 grader. 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_hw4 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 25, 2021.