[WPI] [cs4731]

cs4731, D96/97 Exam 1

Go to Solution

Question 1. A line in 3D is defined by the points P1 = (1,3,­5) and P2 = (5,­5,­3). At what point does the line intersect the yz plane (the plane in which x=0)?

Question 2. Write an algorithm (detailed words, pseudo-code, or code) which fills a polygon (described by a linked-list polyline) with a uniform color. Describe any conditions under which your algorithm will fail.

Question 3. Write a C function which takes as its parameter a pointer to a 4D vector as shown below. Your function normalizes the vector (changing it's values, if necessary) and it returns the int value 0. If the vector cannot be normalized, leave it unchanged and return the value 1.

typedef struct f_point
   {
   float x; /* point coordinates */
   float y;
   float z;
   float w;
   struct f_point *next; /* for linked list */
   } f_point; /* newly defined type */

int normalize_vector(f_point *); /* prototype */

int normalize_vector(f_point *vector) /* your function */
   {

   /*** your code goes here ***/

      /* return 0 if normalization is successful or 1 if not */
   } /* end normalize_vector() */


 
WPI Home Page
[cs4731]

Contents ©1997, Norman Wittels
Updated 05Apr97