function []=Rotate;
%Rotates the letter A through 30,60 and 90 degrees
figure(1);
clf;
% x=[0,4,4,0,0];  % a box
% y=[0,0,3,3,0];
% Make up the x,y coordinates of the letter A, or any other figure
x=[0,2,3,5,4.25,3.5,1.4,1.75,3.25,2.5,1.75,1.4,.75,0];
y=[0,3,3,0,0,1,1,1.5,1.5,2.5,1.5,1,0,0];
%plot the letter A
subplot(221); plot(x,y); fill(x,y,'r');  % color the letter red.See help plot
text(-4,6,'Press a key to continue');
axis([-5 7 -5 7]);
%Rotate 30 degrees
t=-pi/6;
a=cos(t); 
b=sin(t);
T=[a,-b;b,a];  % this is the rotation matrix
M=[x;y];
W=T*M;
pause;  
u=W(1,:); v=W(2,:);
%plot the letter A rotated
subplot(222); plot(u,v);
title('Rotation 30 degrees');
axis([-5 7 -5 7]);
pause
% Rotate 60 degrees
t=-pi/3;
a=cos(t); 
b=sin(t);
T=[a,-b;b,a];
W=T*M;
u2=W(1,:); v2=W(2,:);
%plot the letter A rotated
subplot(223); plot(u2,v2);
axis([-5 7 -5 7]);
title('Rotation 60 degrees');
pause
% Rotate 90 degrees
t=-pi/2;
a=cos(t); 
b=sin(t);
T=[a,-b;b,a];
W=T*M;
u3=W(1,:); v3=W(2,:);
%plot the letter A rotated
subplot(224); plot(u3,v3);
axis([-5 7 -5 7]);
title('Rotation 90 degrees');


