Homework 2

Implement, as a java applet, a simple ray tracer that renders spheres.

You can assume that the camera eye point is at the origin, and that the "film" is a square parallel to the xy plane, 1 unit wide and 1 unit high, centered at aim point [0,0,-3].

Your job will be to loop through your image, rendering each pixel in turn. At each pixel choose an appropriate point on the film square as an aim point. Then ray trace from the camera eye point through that aim point.

You should define the following collection of spheres as your model:

centerx       centery       centerz       radius       color





-1 0-101red
0 1-101.25green
1 0-101blue
0-1-101.25white

At each pixel, determine which sphere is closest to the camera, by implementing the ray-sphere math we covered in class, and use the color of that sphere as the pixel color. If the ray at a pixel does not hit any sphere, then render that pixel as black.