CS465 Fall 2006 Homework 4 Solution ------------------- 1. Stem: Scale by (0.5, 8), then translate by 8 in y: [1 0 0; 0 1 8; 0 0 1] * [0.5 0 0; 0 8 0; 0 0 1] = [0.5 0 0; 0 8 8; 0 0 1] Center: Just translate by 18 in y: [1 0 0; 0 1 18; 0 0 1] Petal 1: scale by (1,2), then translate up by 21.5: [1 0 0; 0 1 21.5; 0 0 1] * [1 0 0; 0 2 0; 0 0 1] = [1 0 0; 0 2 21.5; 0 0 1] Leaf: scale by (1,4), translate by (0,4), then rotate by 60 degrees: [cos(pi/3) -sin(pi/3) 0; sin(pi/3) cos(pi/3) 0; 0 0 1] * [1 0 0; 0 1 4; 0 0 1] * [1 0 0; 0 4 0; 0 0 1] = [cos(pi/3) -4*sin(pi/3) -4*sin(pi/3); sin(pi/3) 4*cos(pi/3) 4*cos(pi/3); 0 0 1] ~= [0.5 -3.4641 -3.4641; 0.8660 2 2; 0 0 1] Petal 2: scale by (1,2), then translate up by 1.5. This places the petal in a coordinate system where the center of the flower is at the origin. Rotate by 2pi/5, then translate by 18 to put the center of the flower where it belongs: [1 0 0; 0 1 18; 0 0 1] * [cos(2*pi/5) -sin(2*pi/5) 0; sin(2*pi/5) cos(2*pi/5) 0; 0 0 1] * [1 0 0; 0 1 3.5; 0 0 1] * [1 0 0; 0 2 0; 0 0 1] = [cos(2*pi/5) -2*sin(2*pi/5) -3.5*sin(2*pi/5); sin(2*pi/5) 2*cos(2*pi/5) 3.5*cos(2*pi/5)+18; 0 0 1] ~= [0.3090 -1.9021 -3.3287; 0.9511 0.6180 19.0816; 0 0 1] 2.a. Stem: Scale along x axis by 0.5 and y axis by 8. Translate along y axis by 8. Center: Translate along y axis by 18. Petal 1: Scale along y axis by 2. Translate along y axis by 21.5. Leaf: Scale along y axis by 4. Translate along y axis by 4. Rotate about origin by pi/3. 2.b. Scale factors can be determined from the size of the ellipse relative to the unit circle. If we scale around a point c, then a point y on the axis that has scale factor s will be mapped to a point y' on the axis that is s times as far away from c. That is, y' - c = s (y - c). We know s, y, and y', so we can solve for c: c = (y' - sy) / (1 - s) Petal 1: Scale is by (1,2) and want to map (0,0) to (0,21.5). Use s = 2, y = 0, y' = 21.5 to get c = -21.5. So the answer is: Scale along x axis by 1 and along y axis by 2 with respect to point (0, -21.5). Leaf: Let u = (cos(pi/3), sin(pi/3)) and v = (-sin(pi/3), cos(pi/3)). Make a coordinate system based on u and v with origin at (0, 0) in the xy coordinate system. In the u-v coordinate system, we have a scale of (1,4) and want to map the point (0, -1) to (0, 0). So use s = 4, y = -1, y' = 0 to get c = -4/3. So the answer (in u-v) is: Scale along u axis by 1 and along v axis by 4 with respect to point (0, -4/3). And the answer in canonical coordinates is: Scale along the axis (cos(pi/3), sin(pi/3)) by 1 and along the axis (-sin(pi/3), cos(pi/3)) by 4, around the center (2/sqrt(3), -2/3). 3. A. Scale along x axis by 0.5 and y axis by 8. Translate along y axis by 8. B. Translate along y axis by 18. C. Scale along y axis by 2. Translate along y axis by 21.5. D. Scale along y axis by 4. Translate along y axis by 4. Rotate about origin by pi/3. E. Rotate Petal 1 about the center of Center by 2*pi/5. F. Rotate Petal 1 about the center of Center by 4*pi/5. G. Reflect Left Half across y axis (the line x = 0). And finally, for your edification here is the MATLAB function that generated the picture in the handout: function hw4 figure; grid on; hold on; axis equal; theta = linspace(0,2*pi,361); unit_circle = [cos(theta); sin(theta); repmat(1, size(theta))]; plot(unit_circle(1,:), unit_circle(2,:)); A = [1 0 0; 0 1 8; 0 0 1] * [0.5 0 0; 0 8 0; 0 0 1]; stem = A*unit_circle; plot(stem(1,:), stem(2,:)); B = [1 0 0; 0 1 18; 0 0 1]; center = B*unit_circle; plot(center(1,:), center(2,:)); C = [1 0 0; 0 1 21.5; 0 0 1] * [1 0 0; 0 2 0; 0 0 1]; petal1 = C*unit_circle; plot(petal1(1,:), petal1(2,:)); beta = 60*pi/180; D = [cos(beta) -sin(beta) 0; sin(beta) cos(beta) 0; 0 0 1] * [1 0 0; 0 1 4; 0 0 1] * [1 0 0; 0 4 0; 0 0 1]; leaf = D*unit_circle; plot(leaf(1,:), leaf(2,:)); beta = 360/5*pi/180; E = [1 0 0; 0 1 18; 0 0 1] * [cos(beta) -sin(beta) 0; sin(beta) cos(beta) 0; 0 0 1] * [1 0 0; 0 1 -18; 0 0 1]; petal2 = E*petal1; plot(petal2(1,:), petal2(2,:)); beta = 2*360/5*pi/180; F = [1 0 0; 0 1 18; 0 0 1] * [cos(beta) -sin(beta) 0; sin(beta) cos(beta) 0; 0 0 1] * [1 0 0; 0 1 -18; 0 0 1]; petal3 = F*petal1; plot(petal3(1,:), petal3(2,:)); G = [-1 0 0; 0 1 0; 0 0 1]; petal4 = G*petal3; plot(petal4(1,:), petal4(2,:)); petal5 = G*petal2; plot(petal5(1,:), petal5(2,:)); leaf2 = G*leaf; plot(leaf2(1,:), leaf2(2,:));