Mid-Semester Exam Solution
Total Page:16
File Type:pdf, Size:1020Kb
CS384G: Computer Graphics October 29, 2001 4:00PM –5:15PM
Mid-Semester Exam Solution
Answer all questions Name______100 points total SSN(last 4 digits)______
Question 1:(24 points) Perform Sutherland Hodgman clipping on each of the figures below to the rectangular clip region shown dashed. Show the intermediate results after clipping with the top edge, the results after clipping with the top and right edges, the results after the top, right and bottom edges, and the final results. (You should show 8 figures in all.).
Answer:
1 Question 2:(21 points) It takes three points to define an affine transformation in 2D. Say that the point (1, 1) goes to
(4, 4), that (1, - 1) goes to (4 + 2 ; 4 - 2 ), and that the point ( -1, 1) goes to (4- 2 , 4- 2 ). Assume that the affine transformation is described by the following homogeneous matrix equation: x' a a b x xx xy x y' a yx a yy by y 1 0 0 1 1 a) Consider the points to be the corners of a triangle. Draw a picture showing the initial and final positions of the triangle, and give a matrix that transforms the initial triangle to the final one. b) Write out six linear equations involving the unknowns in the matrix equation above and the coordinates of the given points. c) Solve the equations to find the unknowns and hence write out the transformation matrix.
Answer: a) The initial position is around the origin, and the final is off to the top right:
The picture suggests that the triangle should be rotated by 45 degrees about the origin, then translated by 4 in the x direction and 4 - 2 in the y direction.
1 1 0 2 2 1 1 The rotation matrix is: 0 2 2 0 0 1
1 0 4 And the translation matrix is: 0 1 4 2 0 0 1 To compute them, the rotation should be multiplied by the translation, with the rotation on the right since it is done first:
2 1 1 1 1 0 4 1 0 4 2 2 2 2 1 1 1 1 0 1 4 2 0 4 2 . 2 2 2 2 0 0 1 0 0 1 0 0 1 b) Putting the first point into the transformation equation gives us: 4 a a b 1 xx xy x 4 a yx a yy by 1 1 0 0 1 1 Expanding this out gives two equations:
4 axx axy bx
4 a yx a yy by Doing the same thing for the other points gives four more equations:
4 2 axx axy bx
4 2 a yx a yy by
4 2 axx axy bx
4 2 a yx a yy by d) Solving these six simultaneous equations gives: 1 axx 2
1 axy 2
1 a yx 2
1 a yy 2
bx 4
by 4 2
3 Hence the matrix is:
1 1 4 2 2 1 1 4 2 2 2 0 0 1
Question 3:(16 points) A pair of transformations is said to commute if the order in which you apply them does not matter. In terms of transformation matrices, that means that AB = BA. Explain which of the following transformation pairs commute in 3D. a) translate – translate b) scale – scale c) rotate – translate d) rotate – scale
Answer: a) A translate and a translate commute: 1 0 0 x 1 0 0 x 1 0 0 x x 1 2 1 2 0 1 0 y1 0 1 0 y2 0 1 0 y1 y2 0 0 1 z 0 0 1 z 0 0 1 z z 1 2 1 2 0 0 0 1 0 0 0 1 0 0 0 1
b) A scale and a scale commute: x 0 0 0 x 0 0 0 x x 0 0 0 1 2 1 2 0 y1 0 0 0 y2 0 0 0 y1 y2 0 0 0 0 z 0 0 0 z 0 0 0 z z 0 1 2 1 2 0 0 0 1 0 0 0 1 0 0 0 1
c) A rotate and a translate do not commute: For example: a rotate about z axis.
4 1 0 0 x cos sin 0 0 cos sin 0 x 0 1 0 y sin cos 0 0 sin cos 0 y 0 0 1 z 0 0 1 0 0 0 1 z 0 0 0 1 0 0 0 1 0 0 0 1
cos sin 0 0 1 0 0 x cos sin 0 x cos y sin sin cos 0 0 0 1 0 y sin cos 0 x sin y cos 0 0 1 0 0 0 1 z 0 0 1 z 0 0 0 1 0 0 0 1 0 0 0 1
The two results are different.
e) A rotate and a scale do not commute: For example: a rotate about z axis. x 0 0 0 cos sin 0 0 x cos x sin 0 0 0 y 0 0 sin cos 0 0 y sin y cos 0 0 0 0 z 0 0 0 1 0 0 0 z 0 0 0 0 1 0 0 0 1 0 0 0 1
cos sin 0 0 x 0 0 0 x cos y sin 0 0 sin cos 0 0 0 y 0 0 x sin y cos 0 0 0 0 1 0 0 0 z 0 0 0 z 0 0 0 0 1 0 0 0 1 0 0 0 1 The two results are different.
Question 4:(24 points) The tangents to the Polynomial Bezier curve at the parameter value t = 0 points along the line joining the first and second control points, and the tangent at t = 1 points along the line joining the second last and last control points. Derive the tangents to the Rational Bezier curve at the
5 parameter values t =0 and t = 1 .
Answer: By the definition of Bezier curve, we have
n n1 n n n n xi Bi ( t ) x0 (1 t ) xi Bi ( t ) xn t i0 i1 n n w B n ( t ) ( w B n ( t ) )2 x( t ) i i i i i0 i0 n n1 . y( t ) n n n n yi Bi ( t ) y0 (1 t ) yi Bi ( t ) yn t i0 i1 n n n n 2 wi Bi ( t ) ( wi Bi ( t )) i0 i0
n n1 n n1 n1 n1 n ( wi Bi ( t ))( nx0 (1 t ) nxi ( Bi1 ( t ) Bi ( t )) nxnt ) i0 i1 x' ( t ) n n 2 ( wi Bi ( t )) i0
n n1 n n1 n1 n1 n ( xi Bi ( t ))( nw0 (1 t ) nwi ( Bi1 ( t ) Bi ( t )) nwnt ) i0 i1 n n 2 ( wi Bi ( t )) i0
n n1 n n1 n1 n1 n ( wi Bi ( t ))( ny0 (1 t ) nyi ( Bi1 ( t ) Bi ( t )) nynt ) i0 i1 y' ( t ) n n 2 ( wi Bi ( t )) i0
n n1 n n1 n1 n1 n ( yi Bi ( t ))( nw0 (1 t ) nwi ( Bi1 ( t ) Bi ( t )) nwnt ) i0 i1 n n 2 ( wi Bi ( t )) i0
For t=0, we have:
w0 ( nx0 nx1 ) x0 ( nw0 nw1 ) n( x1w0 x0 w1 ) x' ( 0 ) 2 2 w0 w0
6 w0 ( ny0 ny1 ) y0 ( nw0 nw1 ) n( y1w0 y0 w1 ) y' ( 0 ) 2 2 w0 w0
For t=1, we have:
wn ( nxn nxn1 ) xn ( nwn nwn1 ) n( xn wn1 xn1wn ) x' (1) 2 2 wn wn
wn ( nyn nyn1 ) yn ( nwn nwn1 ) n( yn wn1 yn1wn ) y' (1) 2 2 wn wn
Question 5:(15 points) 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 last review question, each triangle was partitioned into four smaller triangles with the 1 size reduced 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 4k triangles (with size ) to cover the entire graph in the kth iteration; 3k
7 Therefore the fractal dimension is:
ln 4k ln 4 . lim k k ln3 ln3
8