Computer Science 102

Lab 5

In this lab you will begin the implementation of the sphere.c module.

Components that are provided for you include: main.c, ray.h, rayfuns.h, rayhdrs.h, and a makefile. You must provide your own vector.h and will build sphere.c.

The sphere hits function

double sphere_hits(

vec_t *base, /* ray base (the viewpoint) */

vec_t *dir, /* ray direction unit vector */

object_t *obj) /* the sphere object */

This function must:

Determine if the ray hits the sphere in negative z-space

If so, it must

store the location of the hit point in the object_t struct and

store a unit normal in the object_t structure

return the distance from the viewpoint to the hit point

If not, it must

return(-1);

In this lab you will submit a compressed tar file named sphere.tar.gz containing all the components needed to build your program.

sendlab.102.labsection# lab# sphere.tar.gz

Since this is lab3 and if you are in section 1 the command you should use is (remember to cd .. because that is where you put your tarfile!)

sendlab.102.1 3 sphere.tar.gz

Mike Westall

2007-01-17T09:19:32