% ROTATEMOVIE A basic example of how the movie package works.
%             type 'type rotatemovie' to see the actual program.
%
%             - slow a movie by frame repetition
%             - set axis to vis3d to keep steady shot

% Originally written by ALW, 11/27/95
%
% Last modified by ALW 11/07/02

% use matlab's peak function to create single images, on a coarse grid

[X,Y,F] = peaks;
indx    = [1:2:size(X,1)];
indy    = [1:2:size(X,2)];
figure(1); clf;colormap('hot')

frames = 39;
rep    = 2;
factor = cos((7-0.5)*pi/frames);
surf(X(indx,indy),Y(indx,indy),factor*F(indx,indy));
shading interp
axis([-3 3 -3 3 -7 7])
axis off
axis vis3d
for i = 0:frames
  a = 2*pi*i/(1+frames);
  view([cos(a) sin(a) 1])
  disp(['Creating frame ',num2str(i)]);
  % Create frames with 560 x 420
  makeframe(i,'rotmov',[560,420],256); 
end

fv1 = 0:frames;
fv  = [];
for i=1:rep
  fv = [fv;fv1];
end  

fv = reshape(fv,rep*(frames+1),1)';
% make movie: create file rotate.mpg, the mpeg movie
makemovie(fv,'rotmov','mpg')

disp(' ')
disp('======================')
disp('done with rotatemovie.')
disp('======================')
disp(' ')
disp(' ')


