SUNY Geneseo Department of Mathematics

Homework Project 1—Simple Rays

Math 384
Spring 2015
Prof. Doug Baldwin

Complete by Wednesday, February 4
Grade by Friday, February 6

Purpose

This lesson reinforces your understanding of the mathematics of rays and ray-plane intersections. It also develops your ability to implement that mathematics in code.

Background

This exercise is based on material from our classes on January 23, January 26, and January 28. I also expect to provide time in one or more other classes before the “Complete-By” date to work directly on the programming issues arising in this exercise.

Activity

Complete each of the following parts. The first two are pencil-and-paper exercises on the basic math of rays; the third is the programming part of the project.

Part 1

Give an equation for a ray that originates at point (1,0,5) and that passes through a pixel center at (-0.5,1,4). What are the coordinates of the point this ray passes through when t = 2? At what value of t does the ray intersect the xy plane?

Part 2

The rays we have concentrated on, that meet at a focal point after passing through an image plane, produce perspective images of a scene (or, more technically, these rays perform a perspective projection of the scene onto the image plane). You can also use ray tracing with orthographic projections by making all rays perpendicular to the image plane. Give an equation for such a ray passing through a pixel center at (-0.5,1,4), assuming the image plane is perpendicular to the z axis.

Part 3

Write a ray tracer with the following key features:

This ray tracer obviously works with a very simple scene. You can vary the scene a little bit by adjusting the values of x and y that position the triangle’s vertices on the x and y axes, by changing the triangle’s color, by altering where the focal point is located, and altering how high and wide the image “plane” is and how far it is from the focal point.

I don’t recommend investing effort in making the scene more elaborate than the single triangle described above because the next thing we will look at is how to apply geometric transformations to a single “canonical” triangle (and other objects) in order to create an arbitrary number of arbitrarily shaped, positioned, and oriented “instances” of it. Then we will look briefly at a completely different way of computing ray-triangle intersections. I don’t want to wait for those things before you start getting your own hands on ray tracing, but effort invested now in a fancier scene is likely to be superseded by things we talk about in the next few weeks.

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.