%
% Reads a pic in GIF,JPEG,etc and rotates every point using 
% a matrix (Ricardo Carretero 10/09/03)
%


function  rotate(nameimage,theta)

% read image
[my_image, my_map]=(imread(nameimage));

% size of image
[sy,sx]=size(my_image)

% plot initial image
figure(1)
surf(double(my_image));
view(0,-90)
shading interp;
colormap(my_map);

% rotation matrix
theta=theta*pi/180;
R = [cos(theta) sin(theta); -sin(theta) cos(theta)]

% apply rotation to every point and plot
figure(2); clf; hold on; view(90,90)
for y=1:sy
 for x=1:sx
  v=[x;y];
  vp = R * v;
  colindex=double(my_image(y,x))+1;
  col=my_map(colindex,:);
  plot(vp(2),vp(1),'s','MarkerSize',4.0,'Color',col,'MarkerFaceColor',col)
 end
 if(ceil(mod(y,sy/10))==1)
  pause(0.0000000000001)
 end
end
pause(0.0000000000001)
axis tight

