CS465 Fall 2006 Homework 5 Solution ------------------- 1.1 The main idea is to first rotate V into the plane spanned by two canonical axes (here, we use the Y-Z plane). Then, rotate to align the resulting vector with a canonical axis (here, the Z axis). Now apply the 45 degree canonical rotation around that axis (here, Z), and then undo the first 2 rotations (which can be thought of as rotations by the negation of the original rotations). R_axis_angle = Rz(-atan(2)) * Rx(-atan(2*sqrt(5)) * Rz(pi/4) * Rx(atan(2*sqrt(5)) * Rz(atan(2)) where Rz(theta) and Rx(theta) are the canonical rotations around the z and x axes. Numerically, Rz(atan(2)) = 0.4472 -0.8944 0 0.8944 0.4472 0 0 0 1.0000 Rx(atan(2*sqrt(5)) = 1.0000 0 0 0 0.2182 0.9759 0 -0.9759 0.2182 Rz(pi/4) = 0.7071 -0.7071 0 0.7071 0.7071 0 0 0 1.0000 The resulting matrix is R_axis_angle = 0.9303 -0.0427 0.3644 0.2659 0.7629 -0.5893 -0.2528 0.6451 0.7211 1.2 First, choose a vector that is not parallel with V, like [0 0 1]'. Taking the cross product of V and this vector yields a vector perpendicular to V: V2 = normalize(V x [0 0 1]') = [0.4472 -0.8944 0]'. The cross product of V and V2 will produce a direction perpendicular to both: V3 = V x V2 = [0.1952 0.0976 -0.9759]'. So Rbasis = [V2 V3 V] = 0.4472 0.1952 0.8729 -0.8944 0.0976 0.4364 0 -0.9759 0.2182 And we can express the axis-angle rotation as R_axis_angle = Rbasis * Rz(pi/4) * Rbasis' and the answer is the same as in Problem 1.1. Note that cross(u,v) = -cross(v,u). If you aren't careful to perform cross products in the right order, your basis can be left-handed, which leads to an incorrect answer. 2.1 (B-Spline) a) matrix is [-1 3 -3 1; 3 -6 3 0; -3 0 3 0; 1 4 1 0] / 6. This gives x(t) = 1/2 + t/2 - 3t^2/2 + 2t^3/3 y(t) = 1/6 + t/2 + t^2/2 -2t^3/3 b) t=0 -> (x,y) = (1/2,1/6). t=1 -> (x,y) = (1/6,1/2) c) dx/dt = 1/2 - 3*t + 2*t^2. Solutions t = (3 +- sqrt(9-4*.5*2))/4 = (3 +- sqrt(5))/4 = 0.191, and something > 1. So answer = (.191,.545) dy/dt = 1/2 + t - 2*t^2. Solutions t = (-1 +- sqrt(1+4*2*.5))/-4 = (1 -+ sqrt(5))/4 = 0.809, and something < 0. So answer = (.809,.545) d) see b_spline_poly.png e) see b_spline.png 2.2 (Bezier) a) matrix is [-1 3 -3 1; 3 -6 3 0; -3 3 0 0; 1 0 0 0]. This gives x(t) = -1 + 6*t - 9*t^2 + 4*t^3 y(t) = 0 + 0 + 3*t^2 - 4*t^3 b) t=0 -> (x,y) = (-1,0). t=1 -> (x,y) = (0,-1) c) dx/dt = 6 - 18*t + 12*t^2. Solutions t = (18 +- sqrt(324-4*6*12))/24 = (18+-6)/24 = 1/2 and 1 So answer = (1/2, 1/4) and (1,0) dy/dt = 6*t - 12*t^2. Solutions t = (-6 +- sqrt(36+4*12*0))/-24 = (6-+6)/24 = 0 and 1/2 So answer = (0,0) and (1/2,1/4) d) see bezier_poly.png e) see bezier.png