This is a closed book, closed notes exam. Put your answers and all your calculations in your Blue Book. No calculator is needed or should be used. In drawing diagrams including fractional values, a reasonable approximation suffices. When you are asked to do a transformation step-by-step, write, draw and, comment on the results of each step. For diagrams, label all axes, coordinates, points, and vectors.
For convenience in writing out your answers, vectors can be written in row format, as [x,y] or [x,y,z], and for homogeneous coordinates too, in contrast to the book's column format.
Question 1. Vector algebra. In the figure below, the triangle a,b,c sits symmetrically near the origin, with its outer surface directed away from the origin, towards "you". What you are to compute is the inner product of the unit normal, N, to the triangle, with the vector L = [1,0,0]. When you compute the unit normal, make sure that its magnitude and direction make sense to you -- does your unit normal have the values it should, given the figure? This type of computation is used in calculating the amount of illumination to a surface. In such a case, the vector L would be a vector directed toward the light source.
You should know that the normal is computed using the cross product of edge vectors and you should know how to normalize a vector to create one of unit length, then how to compute the inner product (by components).
Question 2. Geometric transforms in two dimensions. The figure below, shows a line A,B in its original position and the line with corresponding points, A',B' obtained by a pair of transforms, one a rotation and the other a translation.
Your task it to create the translation and rotation matrices required, T and R. The transformations can be designed to be applied in one order or designed with different values to be applied in the other order, giving the same result. (But you'll find that one order is simpler to design than the other.) Do the following:
Question 3. Scan-fill of polygons. The figure below, shows the triangle A,B,C. To the right of it is the structure of one of the edge data elements. Do the following two tasks:
Question 4. Clipping polygons. The figure below, shows a polygon that is to be clipped against a rectangular window. The four cases are illustrated to the right of the polygon figure. Explain how each works. Clip the polygon in the order: bottom, top, right, and left for the window edges. Draw the successive clipping steps as separate figures.
Question 5. Midpoint line algorithm for scan conversion. The Java code below is an excerpt from a working version of the Bresenham midpoint algorithm for scan converting lines. You are to do the following:
public void dobres(int x0, int y0, int x1, int y1){ int y = y0; int d = 2*(y0 - y1)*(x0 + 1) + (x1 - x0)*(2*y0 + 1) + 2*x0*y1 - 2*x1*y0; for (int x = x0; x <= x1; x++) { draw(x,y); if (d < 0) { y++; d += 2*(x1 - x0) + 2*(y0 - y1);} else d += 2*(y0 - y1); } } // dobres()