CS384G: Computer Graphics Oct. 16, 2000 Midterm Exam 1. Given an affine transformation that maps a viewport shown below (left) to another viewport with the same size shown below (right). Give a matrix that expresses this transformation. 50 Answer: 1 0 0 Translation: 0 1 0 Reflection: 10 90 1 1 0 0 0 1 0 Rotation: 3 cos 4 3 sin 4 0 0 0 1 3 sin 4 3 cos 4 0 ( Remember that this is a clockwise rotation. ) 3 cos 4 3 Final matrix = sin 4 0 3 4 3 cos 4 0 sin 0 1 0 .0 0 1 0 1 0 0 1 0 .0 1 0 0 1 0 10 90 1 0 0 1 2 2 2 = 2 0 2 2 0 2 2 50 2 40 2 . 1 2. Consider the standard projective transformation: x y P ( x, y, z ) ( , ,1), z z which projects the points onto the projection plane z 1 . Consider a circle in 3D space, defined by the following equation: C: 1 2 1 2 x ( z ) 2 4. y 1 We know that this circle is projected to a parabola onto the projection plane. (1) Derive the equation of this parabola. (2) What are the homogeneous coordinates of the points at infinity of this parabola in 3D space? (3) Give an example of a circle that is projected to a hyperbola under this transformation (just write the equation, no explanation is required). Answer: (1) We know the projective transformation is: x y P( x, y, z ) ( , ,1) . z z x xˆ z Suppose: , where ( xˆ , yˆ ) are the coordinates of the projected points on the yˆ y z projection plane. Then we have: x xˆ z . y yˆ z Substitute this coordinate transformation into the circle equation, we get: 1 2 1 2 2 xˆ z ( z ) 2 4 yˆ z 1 (1) ( 2) 1 From (2), we have: z , substitute this into (1), and then we get the equation of xˆ , yˆ as: yˆ xˆ 2 1 ( 2 2 yˆ 1 2 1 ) . yˆ 4 Thus the final equation of the parabola is: y x2 1 . z 1 (2) As we know from the review questions, the infinite points of the parabola lie on the direction of + y. Therefore the homogeneous coordinates of those points are: (0, 1, 0, 0). (3) The example circle can be written as: 1 2 2 x z 4. y 1 All circles will satisfy this condition as long as they have two and only two intersection points with the plane z = 0 and the plane containing this circle does not contain the origin. 3. Consider a quadratic Bezier curve determined by three control points: P0 , P1 , P2 . Given any t [0,1] , we have two points A, B on P0 P1 , P1 P2 , respectively, so that the line segment AB is tangent to the Bezier curve at t. (1) For what value of t , does the AP1 B have its maximum area? Prove your answer. (See fig 3.1) (2) For what value of t , is AB // P0 P2 (parallel)? Prove your answer. (See fig 3.2) (3) What are the minimum number of control points required in fig 3.3 to determine the piecewise quadratic Bezier spline curve? Draw them on that figure. (fig 3.1) (fig 3.2) (fig 3.3) Answer: (1) For convenience, we denote a and b as the length of sides P0 P1 , P1 P2 , respectively. Since AB is tangent to the Bezier curve at a point that corresponds to parameter t, we have: AP1 (1 t ) P0 P1 a (1 t ) , and P1 B t P1 P2 b t . The area of AP1 B 1 1 AP1 P1 B sin ab t (1 t ) sin , where is the angle between 2 2 P0 P1 , P1 P2 at vertex P1 . As we know, a, b and are constants here, and t (1 t ) has its maximum value Therefore the answer is: when t (2) Similarly, we have: 1 , AP1 B has its maximum area. 2 1 1 when t . 4 2 AP1 (1 t ) P0 P1 a (1 t ) P0 A t P0 P1 a t P1 B t P1 P2 b t BP2 (1 t ) P1 P2 b (1 t ) and AB // P0 P2 means that: P0 A AP1 P2 B BP1 , or a t b (1 t ) . a (1 t ) bt Thus we have: t 2 (1 t ) 2 , hen we get t 1 . This is the answer. 2 (3). As shown below, at least 11 points are required in this figure. 5 6 1 7 4 0 2 8 3 9 10 4. Consider the limit of the iterated function sequence shown in the figures below (the shade part). What is the fractal dimension of the limit object? Give a brief explanation to your answer. ……… Answer: Similar to the review question # 13, Each triangle was partitioned into four smaller 1 triangles with the size shrinked by times. 3 Take 1 triangle (with size 1 ) to cover the entire graph in the 0th iteration; 1 4 triangles (with size ) to cover the entire graph in the 1st iteration; 3 1 16 triangles (with size ) to cover the entire graph in the 2nd iteration; 9 1 4 k triangles (with size k ) to cover the entire graph in the kth iteration; 3 Therefore the fractal dimension is: ln 4 k ln 4 . lim k ln 3 k ln 3 5. Consider displaying in a 2D circular window. Describe an efficient algorithm to clip any set of convex polygons with your circular window. After being clipped against the window, what is the maximum increase in the number of sides that a resulting clipped polygon might have? Draw an example to illustrate. Answer: (1) Before we begin the polygon-clipping algorithm, we need to know how to compute the intersection points between a line segment and a circle. Suppose AB has expression function as: AB : (1 t ) A t B , (1) and C is described by: ( x cx ) 2 ( y c y ) 2 r 2 . (2) Substitute (1) to (2), we get an equation of t, ((bx a x ) t (a x c x )) 2 ((by a y ) t (a y c y )) 2 r 2 . (3) And then the roots of this equation can be used to compute the intersection points of AB and C. Since in the polygon-clipping algorithm, we check each side of the polygon by a specific direction, thus we need to handle the following five cases based on the roots of equation (3): A A C C B B C A M A A M M C B C B B (Case 1) N (Case 2) (Case 3) (Case 4) (Case 5) Suppose the roots of equation (3) are t1 ,t 2 and t1 t 2 if they exit. Algorithm: Input: (1) Polygon vertices P[0….n-1] (by clockwise or counterclockwise). (2) A circle C: ( x c x ) 2 ( y c y ) 2 r 2 . Output: Q[0….m-1]. // m 2n ; p = 0; // index of P[]; while ( p < n-1 ) A P[ p], B P[ p 1] . Check which case AB should be with circle C (solve equation (3) ): Case 1: t1 0, t 2 1 (completely inside) Keep AB (push A into Q queue); Case 2: t1 ,t 2 do not exit, or t1 t 2 , or t1 , t 2 0 , or t1 , t 2 1 (completely outside) Remove AB . Case 3: t1 0, 0 t 2 1 (from inside to outside) Keep AM and remove MB (push A and then M into Q queue). Case 4: 0 t1 1, t 2 1 (from outside to inside) Keep MB and remove AM (push M into Q queue). Case 5: 0 t1 , t 2 1 (with two intersection points) Keep MN and remove AM , MB (push M and then N into Q queue). Mark M and N; // we will use the marks in the finalize step. p ++; end while // finalize the queue if size of Q equals 0 // size of Q here means the number of vertices pushed into Q. return the clipping circle as the result else for ( k = 0; k < size of Q; k++) A P[k ], B P[k 1] if A equals B Delete A. if both A and B are on circle C and one of them is non-marked Take the circular side of AB instead of line segment AB . end for Note: this algorithm is slightly different from the polygon-clipping algorithm in lecture notes. Here I basically push the starting point into the queue instead of the ending point. (2) Suppose the number of original polygon sides is n. After clipping algorithm, the maximum increase in the number of sides that a resulting clipped polygon might have is n. Here is an example: A D 1 B 8 2 7 3 6 4 5 C
© Copyright 2026 Paperzz