SUNY Geneseo Department of Mathematics

Homework Project 3—Shaded Objects and Shadows

Math 384
Spring 2015
Prof. Doug Baldwin

Complete by Wednesday, March 25
Grade by Friday, March 27
Complete Part 2 by Monday, March 9

Purpose

This lesson reinforces your understanding of how to model shading. It also further develops your understanding of canonical and world coordinate systems.

Background

This exercise is based on material from classes beginning on February 27 and continuing through roughly March 4.

Between March 4 and March 9 you will be doing a part of this exercise that asks you to collectively design data representations and algorithms for the ray tracer you will write later in the exercise. You should collect your design ideas in the Google document at https://docs.google.com/a/geneseo.edu/document/d/1p7YqfgsJ9r_zWvk2sGLEN1cjxwDEU5s10y4SzJT3q6k/edit. This document will, I hope, be a vital foundation for the rest of the exercise.

Finally, Part 1 of the project, the pencil-and-paper part, deliberately expects you to invent or find some methods for calculating normals.

Activity

Complete each of the following parts. The first is a pencil-and-paper exercise on normals and related coordinate system transformations, the second is the design part of the project, and the third is the programming part.

Part 1

Imagine three triangles that are part of a mesh of triangles that approximates a smoothly curved surface. The triangles have vertices

respectively. Notice that many vertices are shared by several triangles. What would be a reasonable estimate of the normal to the surface at vertex ( 0, 1, 0 )? Why?

Now imagine a canonical right cylinder of radius 1 and height 1, with the center of one end on the origin and the axis extending in the positive y direction. A certain ray intersects this cylinder at ( -√2/2, 1/2, √2/2 ). What is the normal to the canonical cylinder at this point?

If the transformation from world coordinates to canonical coordinates for the above cylinder is given by the matrix

	     √3/2  1/2   0  -5/2
	     -1/2 √3/2   0  -5√3/2
	      0     0     1   0
	      0     0     0   1
	

what is the normal in world coordinates? (This transformation is a translation by ( 0, -5, 10 ) followed by a clockwise rotation of π/6 radians.)

Part 2

I have shared a “Ray Tracer 3 Design” Google document with you. This document poses some questions whose answers I think will be critical to coding this ray tracer. These questions deal with representing key data for a ray tracer with shading, and about algorithms for working with that data. Edit this document to contain your collective answers to these questions—the resulting document should be a guide to coding an actual ray tracer in Part 3.

By March 9 this document should contain a tolerably sound design for a ray tracer. Ideally, this will be a single design that you all agree is a reasonable plan for the ray tracer. Coming up with a single design will require that you collaborate on it—as a shared online document, there is neither any reason why it should, nor any expectation that it will, burst forth in final form on March 9. Rather, it should evolve as you think about the problems and jot down ideas in the document: it can start with very preliminary thoughts, you should feel free to edit each others’ contributions, etc. You will need to visit the Google document multiple times during the first few days of the project and make comments on it, edit each others’ suggestions, maybe talk face-to-face about ideas (Friday’s class meeting time would be a logical time to do this, if you want) and then record them in the document, etc. You may well have to negotiate and compromise regarding what you feel is the best way to design a ray tracer.

I will observe and contribute to your work on this document while you work on it. I’ll be happy to suggest answers to questions you run into or make suggestions about points you seem to be stuck on, but I don’t intend to design the ray tracer. That is your job, and I will expect each of you to have identifiable contributions to the final document (Google keeps a complete revision history of documents, so I—and you, if you want—can see what you did even if someone else later replaces it with other ideas).

Part 3

Write Matlab code to implement a ray tracer with the following features, in addition to features found in your first two ray tracers (e.g., canonical objects instantiated to make a scene, a background color, etc.):

I hope that you will find the ideas fleshed out in Part 2 helpful in writing this ray tracer, but you are free to use those ideas or not as you see fit.

Follow-Up

I will grade this exercise in a face-to-face meeting with you. During this meeting I will look at your solution, ask you any questions I have about it, answer questions you have, etc. Please bring a written solution to the exercise to your meeting, as that will speed the process along. For programming parts of the exercise, please bring your code in a form we can read and run (e.g., on a laptop with Matlab installed).

Sign up for a meeting via Google calendar. If you worked in a group on this exercise, the whole group should schedule a single meeting with me. Please make the meeting half an hour long, and schedule it to finish before the end of the “Grade By” date above.