CSC418/2504F, Fall 1999: Assignment 3

Due date: in class, 10 Dec. 1999.

Write your name, ID and cdf login on your written and electronic submissions.

You must answer both questions 1 and 2, and then one of questions 3 or 4.

  1. Cubic curves [6 marks]
    1. [2 marks] Consider a cubic curve interpolating 4 control points: P0(t=-1), P1(t=0), P2(t=1), and P3(t=2). The curve is defined only for 0 <= t <= 1, but would pass through P0 and P3 if extended.

      Derive the basis matrix for this curve.

    2. [2 marks] For the curve in a), sketch the basis functions for 0 <= t <= 1.
    3. [2 marks] Determine the parametric and geometric continuity of the following two curves. Show your work.
      Pa(t) = (t3-2t, 2t3-t, t+1), 0 <= t <= 1
      Pb(t) = (t2-1, t3+1, 2t3+t+2), 0 <= t <= 1




  2. Illumination [4 marks]
    1. [2 marks] Consider a focussed ray of light shining on a smooth, diffuse surface such as a wall. What happens to the light energy that strikes a wall of this type in a room? Be as complete as you can in your answer.
    2. [2 marks] Water in swimming pools often produces strange patterns of light on the bottom and sides of the pool. These are known as caustics. How do these occur?


  3. Animation [15 marks]:

    Create an interesting animation. Sample code is available at:

    Creating an animation will involve the following steps:

    1. Create a hierarchical scene, with several control variables (degrees of freedom).
    2. Choose several key-frames. At each key-frame, choose values for all the control variables.
    3. Animate the scene, by interpolating between key-frames (use cubic interpolation for smoothness).
    The sample code gives you a rudimentary user interface, for setting variables and running animations.

    Once you've created your animation, create a movie file, as follows:

    1. run the program, and record all the frames in PPM files (press the "r" key to start recording). This will create files named "animXXX.ppm", where "XXX" is the frame number.
    2. edit "mpeg.dat", and change the second line to read "anim*.ppm [001-nnn]", where "nnn" is the highest frame number recorded.
    3. type "mpeg_encode mpeg.dat" to create the movie.
    Warning! You may run out of disk space. Keep the window small, to keep the PPM files small. You can also convert PPM files to JPG using cjpeg. The following script may help:
    #!/local/bin/perl
    for (1..60) {
      system sprintf "cjpeg anim%03d.ppm > anim%03d.jpg",$_,$_;
    }
    
    If you do, you must change lines 2 and 4 of mpeg.dat .

    Submit your source code and movie file with one of the following commands:

         submit -N a3q3 csc418h anim.cpp anim.mpg
         submit -N a3q3 csc2504h anim.cpp anim.mpg
    


  4. Ray tracing [15 marks]

    Write a ray tracer which includes the following features:

    1. Polygon, spheres, and cylinder objects.
    2. Shadows.
    3. Reflection and refraction.

    Warning! Ray tracers can easily take hours to render a scene. For all renderings except your final scene, keep the size of your image very small (100x100).

    You may use the solution to the previous assignment:

    if you wish, but it is not required. Adapt the save_image function from question 3 to save your image, and use xv to convert the image to GIF format.

    Submit your source code and image with one of the following commands:

         submit -N a3q3 csc418h rt.cpp rt.gif
         submit -N a3q3 csc2504h rt.cpp rt.gif