                               Computer Science 102
                                  Quiz 1              Name____________________

Please put your name on both front and BACK of your quiz.  Please do not
fold your paper.  You may depart when you finish.

1.  What is the length of the vector (3, 4, 0)





2. Suppose P and Q are points in 3-D space. The vector FROM Q TO P is given
   by:

   a. P - Q                           b. Q - P

   c. P + Q


Suppose vectors P, Q and R are as shown in the figure:

           ^^
          / |
       P /  | R
        /   |
       /    |
      /----->
         Q


Answer the following T (true) or F (false)

____ 3.  Q + P = R


____ 4.  P - R = Q


____ 5.  Q + R = P






                               Computer Science 102
                                  Quiz 2              Name____________________

1. Compute (1, 2, 3) dot (3, -2,  1)




2. Compute  (1, 2, 3) - (3, -2, 1)





3. Which of the following is a unit vector in the direction of a
   arbitrary vector V (circle all that are correct) ||V|| means
   length of V.

   a. V / || V ||                    b. || V || V


   c. V / (V dot V)                  d. V / sqrt(V dot V)




4. In the ray tracing model that we will use:

   a. the viewpoint lies in +z space and  b. the viewpoint lies in -x space and
      the scene lies  in -z space            the scene lies  in +x space

   c. the viewpoint lies in -z space and  d. the viewpoint lies in +x space and
      the scene lies  in +z space            the scene lies  in -x space



5. A unit vector from the viewpoint toward a pixel on the "screen" always has:

   a. a negative x component              b. a negative y component

   c. a negative z component              d. negative x, y, AND z components


                               Computer Science 102
                                  Quiz 3              Name____________________

1. Given the following function prototype and structure

   void camera_getdir(                    typedef struct camera_type
   camera_t *cam,                         {
   int       x,    // pixel coord            int    cookie;
   int       y,    // pixel coord            char   name[NAME_LEN];
   vec_t     dir)                            int    pixel_dim[2];
                                             double world_dim[2];
                                             vec_t  view_point;
                                             irgb_t *pixmap;
                                          }  camera_t;

   identify ALL of the following that will correctly compute the world
   coordinate corresponding to pixel coordinate x.

   a. world[X] = 1.0 * x / (cam->pixel_dim[0] - 1) * cam->world_dim[0];

   b. world[X] = x / (cam->pixel_dim[0] - 1) * cam->world_dim[0];

   c. world[X] = x * cam->world_dim[0] / (cam->pixel_dim[0] - 1);

   d. world[X] = cam->world_dim[0] * x / (cam->pixel_dim[0] - 1);

2. Suppose the screen has (x, y) pixel dimension 801 x 601 and world
   dimension 12 x 9 inches.  The y-world coordinate corresponding to
   pixel location (200, 300) is:

   a. 3                            b. 4.5

   c. 2                            d. none of the above


3.  Suppose the viewpoint is at location V and the world coordinates of the
    point on the screen through which a ray passes is W.  A vector in
    the direction the ray is fired is given by:

    a. V + W                              b. V - W

    c. W - V                              c. (V + W) / 2.0


 4. Suppose a list of the type descibed in class contains 3 objects.
    The number of list_t and link_t structures that are in use is:

    a. 3 list_t and 3 link_t             b. 1 list_t and 5 link_t

    c. 1 list_t and 3 link_t             d. 3 list_t and 1 link_t


5. Suppose list_t *list is a pointer to a list that presently
   has no elements it it. The value of list->first should be:

   a. NULL                             b. the address of list->tail

   c. the address of a link_t          d. the address of the last
      structure                           item that was removed from
                               Computer Science 102
                                  Quiz 4              Name____________________

1. Suppose a list of type list_t contains three items.  The number
   of calls made to free() by list_del() should be

   a. 1                                b. 3

   c. 6                                d. 7

2. Suppose list_t *list is a pointer to a list that presently
   has no elements it it. The value of list->first should be:

   a. NULL                             b. the address of list->last

   c. the address of a link_t          d. the address of the last
      structure                           item that was removed from
                                          the list.

3. Suppose list_t *list points to a correct list header for a non-empty
   list and link_t *link points to a new link structure to be put on
   the end of the list.  Which of the following approaches will correctly
   attach the link to the end of the list.

   a. list->last = link;               b. link->last = link;
      list->last->next = link;            link->next = link;

   c. list->last->next = link;         d. Both a and c but not b.
      list->last = link;

4. Suppose list_t *list points to a correct list header for an empty
   list and link_t *link points to a new link structure to be put on
   the list.  Which of the following approaches will correctly
   attach the link to the start of the list.

   a. list->first = link;               b. list->first = link;
      link->next = list->last;            list->last = link;

   c. list->first->next = link;         d. link->next = list->first;
      list->last->next = link;            list->last = link;


5. Which of one of the following is a correct way to implement
   the list_get_entity(list_t *list) function.

   a. return(list->current);      b. return(list->first);

   c. return(list->link->entity); d. return(list->current->entity);



                               Computer Science 102
                                  Quiz 5              Name____________________

1. Which of the following computations is the correct way to compute the offset
   of a pixel at coordinates (row, col) in a dynamically allocated pixmap?

   a. col * height + row             b. row * col + col

   c. row + col * width              d. row * width + col


2. The proper mapping of (x, y) pixel coordinates (origin at lower left)
   to (row, col) ppm image coordinates (origin at upper left) is:

   a. col = width - 1 - x            b. col = width - 1 - x
      row = height - 1 - y              row = y

   c. col = x                        d. col = x
      row = width - 1 - y               row = width - 1 - y


3. As described in class, the fwrite() function is used to write the
   pixmap to the output image file.  The number of times fwrite()
   should be called is:

   a. once                           b. width of pixmap

   c. height of pixmap               d. width x height

4. Which is the following format strings is correct for reading in
   the location of the viewpoint:

   a. "%d %d"                        b. "%lf %lf"

   c. "%d %d %d"                     d. "%lf %lf %lf"

5. Which is the proper format code to use in reading the { delimiter
   that follows the camera name

   a. %c                            b. %d

   c. %{                            d. %s



                          Computer Science 102
                               Quiz 6      Name ______________________

Given the following definitions and assuming that mod points
to a valid model_t and cam points to a valid camera_t;

typedef struct model_type        typedef struct camera_type
{                                {
   camera_t   *cam;                 int    cookie;
   list_t  *mats;                   char   name[NAME_LEN];
}  model_t;                         int    pixel_dim[2];
                                    double world_dim[2];
model_t  *mod;                      vec_t  view_point;
camera_t *cam;                      irgb_t *pixmap;
                                 }  camera_t;
1. The correct way to store a pointer to the camera_t structure in the model_t
   structure is:

   a. model_t->cam = camera_t       b. list_add(model->cam, cam);

   c. cam->mod = cam;               d. mod->cam = cam;

2. The correct way to check to see if the camera's name is cam1 is

   a. if (cam->name == "cam1")      b. if (strcmp("cam1", cam->name) == 0)


   c. if (strcmp(cam->name, "cam1") = 1) d. Both a and b work correctly


3. The correct way to set the z coordinate of the viewpoint to 5.0 is

   a. cam->view_point[2] = 5.0;    b. cam->viewpoint[2] = 5.0;

   b. cam->viewpoint = 5.0;        d. *cam->view_point = 5.0;

4. The correct wy to allocate a pixmap is:

   a. cam->pixmap = malloc(sizeof(irgb_t));

   b. cam->pixmap = malloc(sizeof(irgb_t * cam->pixel_dim[X] *
                                           cam->pixel_dim[Y]));

   c. cam->pixmap = malloc(sizeof(irgb_t) * cam->pixel_dim[X] *
                                           cam->pixel_dim[Y]);

   d. cam->pixmap = cam->pixel_dim[X] * cam->pixel_dim[Y];

5. Suppose ipix_t *ipix has been set up as follows and
   dpix is a dpix_t.  The proper way to store the red component
   of dpix into the pixel pointed to by ipix is:

   row = cam->pixel_dim[1] - y - 1;
   col = x;
   ipix =  cam->pixmap + row * cam->pixel_dim[0] + col;

   a. ipix[R] = dpix[R];              b. fprintf(stdout, "%d", (*ipix[R]));

   c. (*ipix)[R] = dpix[R];           d. ipix[R] = *dpix[R];

                          Computer Science 102
                               Quiz 7      Name ______________________

1. The proper way to run camtest under control of gdb is:

   a. gdb camtest < camera.txt 1> out.ppm  b. gdb camtest
      run                                     run


   c. gdb camtest                          d. gdb
      run < camera.txt 1> out.ppm             run camtest < camera.txt

2. When single stepping gdb, the command that is used to cause it to
   step "over" a call to a standard library function such as malloc
   and on to the next line of C code in the function being debugged
   is:

   a. s(tep)                          b. n(ext)

   c. o(ver)                          d. r(un)


3. To cause gdb to end stepping and resume "full speed" execution of
   the program from the current location use the command:

   a. c(ontinue)                      b. re(sume)

   c. o(ver)                          d. r(un)

4. The use hierarchies of increased specialization in object oriented
   design underlies the concept of:

   a. polymorphism                   b. inducement

   c. homeomorphism                  d. inheritance

5. We will use function pointers in C to implement to object oriented
   concept of:

   a. polymorphism                   b. delusion

   c. homeomorphism                  d. inheritance



                               Computer Science 102
                                  Quiz 8              Name____________________

1. Which is the proper way to declare a pointer to a function that returns
   an int and takes two ints as parameters:

   a. int pfun(int, int);          b. int *pfun(int, int);

   c. int *(pfun)(int, int);       d. int (*pfun)(int, int);


2. Which is the proper way to make the pointer point to a function
   named adder.

   a. pfun = adder;               b. pfun = adder(0, 0);

   c. *pfun = adder;              d. pfun = *adder;

3. Which is the proper way to invoke the function

   a. sum = pfun(3, 4);           b. sum = &pfun(3, 4);

   c. sum = *(pfun)(3,4);         d. sum = (*pfun)(3, 4);


Suppose object_t *obj and plane_t *pln are pointer to a generic
object structure and a plane structure respectively.

4. The proper way to set the "priv" pointer in the object_t structure is:

   a. pln->priv = obj;             b. obj->priv = pln->priv;

   c. obj->priv = pln;             d. obj->priv = priv;


5. In the following definition, which tokens will be consumed by
   the object_init() funtion.

plane leftwall
{
   material green
   normal 1 0 0.2
   point  0 0 0
}

  a. All of them                   b. plane leftwall
                                      {


  c. plane leftwall                d.         leftwall
     {                                {
        material green                   material green
                          Computer Science 102
                               Quiz 9      Name ______________________

1. Suppose a ray is fired from the viewpoint V in direction D
   hits the plane at a distance t from V. The coordinates of the
   hitpoint are:

   a. P + tN                       b. V + tP

   c. D + tV                       d. V + tD


2. Suppose a plane in 3 dimensional space has normal vector N and the
   P and Q are two different points that both lie in the plane.  Which
   of the following will always have the value 0.

   a.  P dot (Q - N)               b. N dot (P - Q)

   c.  N dot P                     d. P dot (N - Q)


3. Suppose a ray is fired from viewpoint V with unit direction vector D.
   The ray is parallel to the plane if:

   a. V dot D = 0                  b. V dot N = 0


   c. D dot N = 0                  d. (N - D) dot V = 0



4. Suppose a plane is defined by N = (0, 0, 1) and Q = (4, 8, -6)
   where N is the normal and Q is a point on the plane. Suppose
   V = (4, 2, 3) and D = (0, 0, -1)

   a. The distance from V to the Hitpoint?






   b. Give the coordinates of the Hitpoint







    Hint: Although it is possible to solve this using the plug and pray
    method with formulas presented in class, this approach will take
    excessive time and is likely to produce arithmetic errors.  The correct
    approach is to visualize the geometry of the problem in your head
    (or on paper).  If you do that correctly,  the solution can be
    readily computed in your head with resorting to any dot products.

                          Computer Science 102
                               Quiz A      Name ______________________

1. Suppose a sphere is defined by Center = (6, 3, -8) and Radius = 3
   Suppose  Viewpoint = (6, 3, 4) and Direction = (0, 0, -1).  What
   are the coordinates of the hitpoint ?







Finding the intersection of a ray with a sphere requires solving
a quadratic equation.

2. The ray misses the sphere entirely if:

   a. The discriminant is < 0             b. The discriminant is > 0

   c. The discriminant is 0


3. The ray passes through the surface of the sphere at two points if


   a. The discriminant is < 0             b. The discriminant is > 0

   c. The discriminant is 0


4. The correct root of the equation to use in determining the hitpoint is

   a. t = (-b - sqrt(b^2 - 4ac))/2a    b. t = (-b + sqrt(b^2 - 4ac))/2a

   c. Either one will work fine


5. Suppose the center of the sphere is located at C and P is a point
   on the surface of the sphere.  The normal to the surface at P is

   a. C - P                            b. P - C

   c. P                                d. C




                             Computer Science 102
                                   Quiz B

1.  The model_load_attributes() function should include call(s) to

    a. camera_init()                  b. camera_load_attributes()

    c. both                           d. neither one


2. Suppose a tiled plane description looks like:

  tiled_plane floor
  {
     material white
     normal   0 1 0
     point    0 0 0
     dimension 2.0 3.0
     altmaterial green
  }

  For each element of the definition shown below identify the function
  responsible for reading in the element (some answers might be used more
  than once or not at all.

  ___ a. tiled_plane        1. object_init()

                            2. plane_init()
  ___ b. floor
                            3. tplane_init()

  ___ c. point              4. model_init()


  ___ d. green



                          Computer Science 102
                               Quiz C      Name ______________________

1. Which of the following is NOT always an attribute of a rotation
   matrix

   a. its rows are mutually       b. all of its elements are 0
      orthogonal

   c. its inverse is its          d. its rows and columns are
      transpose                      unit vectors


2. Suppose we have two orthogonal unit vectors V and W and we
   wish to construct a rotation that will rotate V into the Z
   axis and W into the X axis.   Identify the proper contents
   of each row of the rotation

   _____ Top row                    a. V

                                    b. W
   _____ Middle row
                                    c. W x V

   _____ Bottom row                 d. V x W


3. Suppose a list class has the following components:

class list_t
{
public:
   list_t(void);                 // constructor
   list_t(const list_t &);       // copy constructor
  ~list_t(void);                 // destructor
   void   add(void *entity);     // add entity to end of list
   void   reset(void);           // set current to start of list

 and a list has been created as follows:

 list_t *list = new list;

 The correct way to add an element to the list is:

 a. list->list_add((void *)elem);   b. list->add((void *)elem);

 c. list->list_add(list, (void *)elem);

 d. list->add(list, (void *)elem);




                          Computer Science 102
                               Quiz D      Name ______________________

1. Suppose the camera_t class has a private member named cookie.  Within
   a camera_t member function the value can be correctly accessed in which
   of the following ways (circle ALL that are correct)

   a. cookie = CAM_COOKIE;             b. this.cookie = CAM_COOKIE;

   c. this->cookie = CAM_COOKIE;


2. In a C++ program a function whose mission is to process a collection
   of object_t's (e.g. the find_closest_object() function)

   a. must be an object_t class method     b. must be a standalone C function

   c. either way works fine.


3. When a new instance of a plane_t is created

   a. only the plane_t's constructor      b. only the object_t's constructor
      will be called                         will be called

   c. the plane_t's constructor will      d. the object_t's constructor will
      execute after the object_t's           execute after the plane_t's
      constructor completes.                 constructor completes


4. The proper way to begin an plane_t class method printer whose implementation
   is outside the class definition is:

   a. void plane_t::printer(         b. void printer::plane_t(
      FILE *out)                        FILE *out)

   c. plane_t::void printer(         d. void printer(plane_t::
      FILE *out)                        FILE *out)


5. Suppose the model_t constructor begins as follows and the model class
   definition contains the list's shown here:

   model_t::model_t(                   class model_t
   FILE *in)                           {
   {                                   public:
       model_t *model = this;                        model_t(FILE *);
                                          void       print(FILE *);
                                          camera_t   *cam;
                                          list_t     *mats;
                                          list_t     *objs;
                                          list_t     *lgts;

   Identify any of the following that will cause actual compile errors

   a.  this->mats = new list_t;      b. modlel->lgts = new list_t;


   c. objs = new list_t;
                          Computer Science 102
                               Quiz E      Name ______________________

1. When a new instance of a plane_t is created

   a. only the plane_t's constructor      b. only the object_t's constructor
      will be called                         will be called

   c. the plane_t's constructor will      d. the object_t's constructor will
      execute after the object_t's           execute after the plane_t's
      constructor completes.                 constructor completes


2. The proper way to begin an fplane_t class method printer whose implementation
   is outside the class definition is:

   a. void fplane_t::printer(         b. void printer::fplane_t(
      FILE *out)                        FILE *out)

   c. fplane_t::void printer(         d. void printer(fplane_t::
      FILE *out)                        FILE *out)

3. Suppose the fplane_t printer function contains the following syntax

   void fplane_t::printer(
   FILE *out)
   {
      plane_t::printer(out);

   which is designed to invoke the printer function of the plane class
   just above it.  Circle all of the answers below that are TRUE.

   a. this is THE correct way to do         b. the presence of plane_t::
      what is intended                         will cause a syntax error
                                               and it needs to be removed
   c. removing plane_t:: will result
      in an infinite recursion in which     d. the program will work as
      fplane_t::printer repeatedly             intended with or without
      calls itself.                            plane_t::


4. The fact that a plane_t is derived from an object_t is defined in:

    a. The plane_t class definition          b. The object_t class definition

    c. The plane_t constructor               d. The object_t constructor


5. The object_t constructor to be used when a new plane_t is created
   is specified in:

    a. The plane_t class definition          b. The object_t class definition

    c. The plane_t constructor               d. The object_t constructor

                          Computer Science 102
                               Quiz F      Name ______________________

1. The diffuse intensity of the light reflected by an object at the
   hitpoint is a product of the emissivity of the light, the
   diffuse reflectivity of the object and the dot product of

   a. unit vectors pointing           b. a unit normal at the object
      in the direction of the            hitpoint and a unit vector
      light and the direction            in the direction of the viewpt
      of the viewpt from the hit

   c. a unit normal at the object     d. unit vectors pointing from the
      hitpoint and a unit vector         light to the object and the
      in the direction of the light      light to the viewpoint

2. (a continuation of 1) divided by:

   a. the distance from the light     b. the distance from the light to
      to the viewpt                      the hitpoint

   c. the distance from the hitpoint
      to the object

3. If the dot product in #1 is negative it means that

   a. the hit object occludes itself  b. the hit object is occluded by
      from the light                     another object

   c. the center of the light is
      visible from the hitpoint

4. In the computation of question 1,

   a. It is REALLY necessary to use    b. it will work OK as long as
      unit vectors                        one of the vectors is a unit
                                          vector

   c. It doesn't really make any
      difference whether unit vectors
      are used or not.

5. When computing diffuse refectivity as described in questions (1) and
   (2) the value that is computed

   a. MUST be stored in the "diffuse"  b. Must NOT be stored in "diffuse"
      drgb_t of the material_t            drgb_t of the material_t

   c. It doesn't matter where it is
      stored.


                          Computer Science 102
                               Quiz G      Name ______________________

1. Given the following function prototype:

   friend inline void vec_sum(vec_t &, vec_t *, vec_t *);

   and the following declarations:

   vec_t v1, v2, v3;

   The proper way to invoke the function is:

   a. vec_sum(v1, v2, v3);               b. vec_sum(v1, &v2, &v3);

   c. vec_sum(v1, v2, &v3);              d. vec_sum(&v1, &v2, v3);


2. Given the following function prototype:

   friend inline void vec_sum(vec_t &, vec_t &, vec_t *);

   Identify ALL of the following definitions that would cause illegal
   duplication

   ___ a. friend inline void vec_sum(vec_t *, vec_t *, vec_t *);


   ___ b. friend inline void vec_sum(vec_t &, vec_t  , vec_t *);


   ___ c. friend inline void vec_sum(vec_t *, vec_t &, vec_t *);


3. Suppose the intent is to cause the sum to be stored in the third
   vector passed to vec sum.  Identify all of the following cannot produce
   the desired result.

   ___ a. friend inline void vec_sum(vec_t *, vec_t *, vec_t *);


   ___ b. friend inline void vec_sum(vec_t &, vec_t  , vec_t &);


   ___ c. friend inline void vec_sum(vec_t *, vec_t &, vec_t );


4. Given the following function prototype:

   void vec_sum(vec_t &v1,  vec_t  v2, vec_t *v3);

   Assuming the objective is to put the sum of the v1 and  v2 in v3
   which is the correct approach:

   ___ a. v3->x = v1->x + v2.x;

   ___ b. v3->x = v1.x + v2.x;

   ___ c. v3.x = v1->x + v2.x;

                          Computer Science 102
                               Quiz H      Name ______________________


1. Suppose V and W are vec_t's and a is a scalar double.  For each of
   the following operator overloads indicate whether the overload COULD
   BE a class method or MUST BE a friend function:

   V + W       a. class method          b. friend function

   a * W       a. class method          b. friend function

   V * a       a. class method          b. friend function

   !V          a. class method          b. friend function


2. If I want to overload the * operator to support BOTH a * V and
   V * a,

   a. I MUST write two separate          b. I must write ONLY one
      operator* functions                   operator*

   c. Depending on my approach I can
      use either one or two
      operator* functions


3. Suppose I want to define a cross product operator.  Which of the
   following can I use.  Circle all that are correct.

   a.  W * V                             b. W ! V

   c.  W x V                             d. W & V


4. Suppose I want to define a vector length operator.  Which of the
   following can I use.  Circle all that are correct (even if they
   are not particularly reasonable)


   a. |V|                                b. !V

   c. +V                                 d. |V



                          Computer Science 102
                               Quiz I      Name ______________________

1. In the rotation matrix used in the fplane_t the plane's unit
   normal vector becomes

   a. row 0                            b. row 1

   c. row 2                            d. its not used in the matrix

2. row 1 of the rotation matrix is constructed as:

   a. row 2 x row 0                    b. row 0 x row 2

   c. the projection of the
      xdir on the y axis

3. The transformation of the hit point that is done in hit testing
   is.

   a. a subtraction followed           b. a rotation followed by
      by a rotation                       a subtraction

   c. a rotation and a a subtraction
      but the order doesn't matter

4. After the hit point is properly transformed

   a. its x coordinate must be            a. its y coordinate must be
      approximately 0                        approximately 0

   c. its z coordinate must be            d. none of its coordinates
      approximately 0                        need to be near 0.


5. Circle all that are true with respect to the input xdir

   a. it must be parallel to           b. it must not be parallel
      the plane                           to the plane normal

   c. Its y and z coordinates          d. it must be perpicular
      must both be 0.                     to the plane normal.


                          Computer Science 102
                               Quiz J      Name ______________________

Consider the conical spotlight in which the emitted light is constrained
by a conical shade.

1.  Suppose the spotlight is illuminating a plane.  The area illuminated will
    be circle if

    a. the dot product of the centerline  b. the dot product of the centerline
       direction and the plane normal is     direction and the plane normal is
       0                                     -1

    c. never                              d. always


2. Suppose costheta holds the cosine of the angle of the halfwidth of the cone.
   A point on the plane is illuminated if and only if the dot product of a unit
   vector from the light to the hitpoint is

   a. positive                            b. negative

   c. > costheta                          d. < costheta


3. To compute n! as quickly and efficiently as possible, the preferred
   approach is to:

   a. use recursion                     b. use a single for loop

   c. use nested for loops              d. all three are equally good


4. Complete the following function that will RECURSIVELY return the SUM
   1 + 2 + 3 + ... + n when called with a positive integer parameter n

   int summer(
   int n)      // return sum 1 + 2 + ... + n
   {



                          Computer Science 102
                               Quiz K      Name ______________________

1. Write down all the possible different combinations of the letters
   {a, b, c, d} taken TWO at a time.







2. In the maze problem, one cause for a move being declared "illegal" was
   that the coordinates of the proposed move lay OUTSIDE THE MAZE.  Another
   was that the move was inside the maze but had the value 1. What is the
   other condition that makes a move illegal.






3. There are THREE conditions under which the recursive raytracing
   stops.  One is that the reflected ray doesn't hit any object.
   What are the other two:


   a.



   b.



4. When specular reflection occurs and raytrace() is to be called recursively
   the base of the new ray is

   a. the viewpoint                b. the light that illuminates
                                      the surface

   c. the hitpoint of the current
      ray.





                          Computer Science 102
                               Quiz L      Name ______________________

1. In creating specular glints a shininess exponent is used.
   Which of the following best characterizes the useful range
   of values for the shininess exponent.


   a. 0.0 to 1.0                          b. 1.0 to 10.0


   c. 50.0 to 300.0                       d. 10^8 to 10^10


2. The visible area of the glint effect is made smaller by:

  a. decreasing the shininess             b. increasing the shininess

  c. its independent of the
     shininess

3. In the approach to anti-aliasing that was discussed in class,
   the number of rays traced per pixel

   a. is still one ray per pixel     b. is some constant number > 1

   c. is a random number of rays


4. To perform antialiasing ray direction should be randomized.  In the
   method proposed in class this was done by adding a random offset to

   a.  The x, y components           b.  The (x, y) pixel coordinates
       dir.x and dir.y of the            of the point at which the ray
       direction vector                  was fired


   c. The (x,y) world coordinates
      of the point at which the
      ray was fired.

5. The value to be added in the randomization should be in the range:
   procedure should be

   a. (0, 1)                         b. (-0.5, 0.5)

   c. (0, 0x7ffffff)


                          Computer Science 102
                               Quiz M      Name ______________________

1. To sort 10 items with bubblesort

   a. it is necessary to make 10 passes   b. 9 passes will suffice
      over the data

   c. 1 pass will suffice.

2. For most efficient sorting with bubblesort

   a. the length of each successive pass  b. the length of each successive pass
      should increase by                     should stay the same.

   c. the length of each successive pass
      should decrease by one

3.  Suppose the following items are to be sorted into increasing
    order with bubblesort.   Write the contents of the array
    after the first pass.

    5 4 8 2 10 3



4. When ray_trace() is called recursively because a partially
   transparent object is hit, when making the recursive call:

   a. both the base and direction    b. the direction must be altered
      of the ray must be altered.       but the base stays the same.

   c. the base must be altered but   d. both stay the same.
      the direction stays the same


5. When the light illuminating an object passes through a partially
   transparent object

   a. its intensity will be reduced  b. Its intensity will increase
      but its color won't change        and its color will change

   c. its intensity will increase    d. Its itensity will be reduced
      but its color won't change        and its color may change.
                          Computer Science 102
                               Quiz N      Name ______________________

1. In the texture mapping algorithm the size of a pixel in world coords
   is used in:

   a. texture_tile()                      b. texture_fit()

   c. both of them                        d. neither one


2. Suppose the size of the screen in world coordinates is 8 units wide
   and 6 units tall.  Suppose the size of the output image is 400 pixels
   wide and 300 pixels tall. What is the size of a pixel in world coords?





3. Suppose a texture of size 200 pixels wide by 400 pixels tall
   is being mapped in stretch to fit mode onto a finite plane of
   size 5 units wide and 4 units tall. Suppose the translated and
   rotated hitloc is (4.0, 2.0, 0.0). Give the x texel coordinate in
   pixel units assuming a lower left texture origin


   texel x-coord (column)  =




4. Suppose a texture of size 100 pixels wide by 50 pixels tall is
   being mapped in tiled mode onto a finite plane of size 5 units
   wide and 4 units tall. Suppose that a pixel size is 0.01
   in world coordinates and that the hit point is (2.95, 1.57)
   Give the texel coordinates in pixel units assuming a lower left
   texture origin (DONT perform the upside down correction)


   texel x-coord (column)  =



5. The texplane_t class is directly derived from  the:

   a. plane_t                               b. fplane_t

   c. object_t                              d. light_t
                          Computer Science 102
                               Quiz O      Name ______________________

1. Two new methods required by the projector type light included

   a. getemiss and getdiff                b. vischeck and illuminate

   c. vischeck and getdiff                d. getemiss and vischeck

2. When searching a sorted table of 1,000,000 records with binary
   search the MAXIMUM number of comparisons required is closest to:

   a. 1,000,000                           b. 500,000

   c. 20                                  d. 2

3. In creating his new projector_t class,  Dr. Westall employed an
   ugly hack using a global variable to avoid parsing problems that
   would have occured in which constructor:

   a. projector_t                         b. light_t

   c. texplane_t                          d. object_t


4. The ugly hack of setting and unsetting the "dontlook" variable
   actually took place in:

   a. projector.cpp                       b. model.cpp

   c. object.cpp                          d. light.cpp


5. The projector is a DIRECT descendent of

   a. object_t                            b. fplane_t

   c. texplane_t                          d. tplane_t

                          Computer Science 102
                               Quiz P      Name ______________________

1. If it is necessary to access a common global variable from two
   different .c files which of the following should be used:

   a. int dontlook;  in one and        b. static int dontlook; and
      static int dontlook;                extern int dontlook;
      in the other

   c. int dontlook;  and               d. int dontlook; and
      extern int dontlook;                int dontlook;


2. A diagonal line connecting the y axis to the x axis creates what
   surface of revolution.

   a. cone                            b. cylinder

   c. sphere                          d. cube


3. A vertical line extending upward from the  x axis creates what
   surface of revolution.

   a. cone                            b. cylinder

   c. sphere                          d. cube


4. Suppose a revsurf is given by  f(x, y, z) = x^2 - y^2 + z^2 = 0
   The surface is a:

   a. cone                            b. cylinder

   c. sphere                          d. cube


5. A general revsurf is expressed as  f(x, y, z) = x^2 - g(y)^2 + z^2 = 0
   A point (x, y, z) is INSIDE the surface if:

   a. f(x, y, z)  = 0                 b. f(x, y, z) < 0

   c. f(x, y, z) > 0                  d. all of the above.

