Here's the '99 midterm solutions: 1a) P1 code is [1000] P2 is [0110] it's neither a trivial accept, not reject, so must clip 1b) P1' [0000] P2 is still [0110] still have to clip P1'_x = 2 (clipped against left egde where xwmin = 2) P1'_y = P1_y + m (xwmin - P1_x) = = 5 + (7/14)*(2-1) = = 5 + 1/2 = 5.5 1c) P1' still [0000] P2' is clipped against the top, but code is still [0100] - have to clip p2'_x = P1_x + (ywmax - P1_y)/m = = 1 + (10-5)/.5 = = 1 + 10 = 11 1d) P1' is [0000] P2'' is [0000] - a trivial accept, done! P2''_y = 9.5 1e) no further work needed 2a) Calculate the cross product of two vectors in the plane N = (B-a) x (C - A) = [-1 1 0] x [-1 0 1] = [1 1 1] the plane equation is x+y+z=1 2b) Calculate the cross product P of N and (C - A) P = ( C - A ) x N = [-1 0 1] x [1 1 1] = [1 +2 -1] The plane equation is -x+2y-z+d=0. To figure out what d is, plug in a point that we know is on the plane, eg. point A, we get -1+0+0+d = 0, hence d = -1. The full equation is -x+2y-z-1=0. 3a) The matrix is cosT sinT 0 0 -sinT cosT 0 0 0 0 1 0 0 0 0 1 where T is a function of Z 3b) T = 90*z (ask yourself: what do I multiply z with so that I can get 45 when z is 1/2 ?) 3c) A twist is essectially a rotation, and a determinant of a rotation matrix is always 1 (don't have to know determinants for this exam) 4) An alternative solution to what we did in the review session today: Consider it a rotation of 45 degrees, followed by a shear in the X direction of magnitude Alpha, followed by an inverse rotation of 45 degrees, AKA R(45), SHx(Alpha), R(-45) the matrices are: cos45 sin45 -sin45 cos45 1 1 ---------------------- 1 0 0 0 Aplha 1 0 0 0 0 1 0 0 0 0 1 --------------------- cos(-45) sin(-45) -sin(-45) cos(-45) 1 1 5) Void CircleOf8 (float r, object o) { float dtheta = 360/8; for (int i; i<8; i++) { glPushMatrix(); glRotate(dtheta*i, 0, 0, 1); glTranslate(r, 0, 0); drawObject(o); glPopMatrix(); } } 6a) for orthogonal, just drop the z. Pp:(15, 20, 0) 6b) cabinet is foreshortened by 1/2, so the length in Z will be the half of what it used to be. X and Y dimensions will change cos(30) and sin(30) respectively. The matrix that accomplished this is: 1 1 sqrt(3) 1 ------- --- 1 2*2 2*2 1 6c) Two ways to go about it: - use the perpective projection matrix 1 1 1 1/10 1 to calculate it - use similar triangles to see that for x, 15/(10+25) = x'/10 hence x'= 150/35. Similarly, y'=200/35 --------------------------------------------------------------------------- -------------------------------------------------------------------------- Midterm '98 1) When m>1, the angle of inclination of the line is > 45 degrees, so we step in the y direction and calculate the corresponding x. In the given equation, we can substitute b with y_i-m*x_i (from y = m*x + b) we also know m = delta_y/delta_x so from P1 = -2*delta_y*x_i + 2*delta_x*(y_i-b) + 2*delta_x - delta_y (algebra here) = -delta_y +2*delta_x P1 = d1-d2, we know that of P1 < 0, that means d1