rotate_triangle - % Perform rotation. R = [cos(theta)...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
% rotate_triangle.m For problem 11(a) % Create matrix whose columns contain the coordinates of each vertex. U = [5 6 4; 0 2 1]; theta = pi/2; % Create a red triangle. Note U(1,:) denotes the first row of U. fill(U(1,:),U(2,:),'r') hold on % Set the axis. axis([-2 2 -2 2]); for i=1:3, % Rotate through angle pi/2 three times.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Perform rotation. R = [cos(theta) -sin(theta); sin(theta) cos(theta)]; U = R*U; if i==1, fill(U(1,:),U(2,:),'b'); end; % Use different colors for rotated triangles. if i==2, fill(U(1,:),U(2,:),'g'); end; if i==3, fill(U(1,:),U(2,:),'c'); end; end; axis equal tight, grid on...
View Full Document

This note was uploaded on 12/08/2009 for the course AMATH 10211 taught by Professor Annegreenbaum during the Spring '09 term at University of Washington.

Ask a homework question - tutors are online