MAT 343 MATLAB 4 - MAT 343 MATLAB LAB 4 QUESTION 1 T =-0.5 0 0.5-0.5-1 1-1-1 plot(T(1,T(2'linewidth,2 hold on R =[0 1 1 0 RT = R*T%Reflect Triangle

# MAT 343 MATLAB 4 - MAT 343 MATLAB LAB 4 QUESTION 1 T =-0.5...

This preview shows page 1 - 3 out of 4 pages.

MAT 343 MATLAB LAB 4 QUESTION 1 T = [-0.5, 0, 0.5, -0.5; -1, 1, -1, -1]; plot(T(1,:),T(2,:), 'linewidth' ,2) hold on R = [0, 1; 1, 0]; RT = R*T; %Reflect Triangle plot(RT(1,:),RT(2,:), '-r' , 'linewidth' ,2) title( 'Reflect Triangle' ) legend( 'Original triangle' , 'Reflect triangle' ) grid on axis equal hold off QUESTION 2 T = [-0.5, 0, 0.5, -0.5; -1, 1, -1, -1]; plot(T(1,:),T(2,:), 'linewidth' ,2) hold on R = [0, 1; 1, 0]; Q = [cos(pi/4), -sin(pi/4); sin(pi/4), cos(pi/4)]; RQT = R*Q*T; plot(RQT(1,:),RQT(2,:), '-r' , 'linewidth' ,2) title( 'Rotated Triangle' ) legend( 'Original triangle' , 'Rotated triangle' ) hold off
QUESTION 3 clf % clear all settings for the plot T = [-0.5,0,0.5,-0.5;-1,1,-1,-1]; Q = [cos(pi/20), -sin(pi/20); sin(pi/20), cos(pi/20)]; QT = Q*T; p = plot(QT(1,:),QT(2,:)); % plot the triangle axis([-2,2,-2,2]) % set size of the graph axis square % make the display square figure(gcf) % display graphics window % Adjust the windows on your screen so that both the command window % and the graphics window show hold on % hold the current graph for i = 1:40 T = Q*T; % transform the figure set(p, 'xdata' ,T(1,:), 'ydata' ,T(2,:)); % erase original figure and plot pause(0.1) end for i = 1:40 T = Q'*T; % transform the figure set(p, 'xdata' ,T(1,:), 'ydata' ,T(2,:)); pause(0.1)

#### You've reached the end of your free preview.

Want to read all 4 pages?

• Fall '08
• ringhofer
• Computer Graphics, homogeneous coordinates, Transform fault