clf
e1=engrenage(1,40,0.2,0.2,0,0,0,0,1);
hold on
[x,y,z]=cylinder([0.1 0.1 0.1 0.1 0.1 0.1]);
e2=surface(x,y+1.5,1.3*z+0.2,2.*ones(size(x)));
e3=surface(x,y,-0.8*z-0.2,3.*ones(size(x)));
e4=surface(x,y+3.1,0.8*z+1.7,4.*ones(size(x)));
e5=engrenage(0.3,20,0.2,0.2,0,1.5,0,0,5);
e6=engrenage(1.2,45,0.2,0.2,0,1.5,1.5,0,6);
e7=engrenage(0.2,15,0.2,0.2,0,3.1,1.5,0,7);
% Žclairage
light('position',[-5,-5,1]);
light('position',[-5,-5,10]);

view(3)
% colormap(cool)
axis image
axis off
set(gcf,'renderer','zbuffer')
set(gcf,'color','w')

% Animation
figure(gcf)
% i=0;
while 1
    rotate(e1,[0 90],1,[0 0 0])
    rotate(e2,[0 90],-40/20,[0 1.5 0])
    rotate(e3,[0 90],1,[0 0 0])
    rotate(e4,[0 90],(40/20)*(45/15),[0 3.1 0])
    rotate(e5,[0 90],-40/20,[0 1.5 0])
    rotate(e6,[0 90],-40/20,[0 1.5 0])
    rotate(e7,[0 90],6,[0 3.1 0])
    drawnow
    % f=getframe(gcf);
    % i=i+1;
    % nom=['0000',num2str(i)];
    % nom_f=['capt',nom(length(nom)-4:length(nom))];
    % imwrite(f.cdata,nom_f,'png')
end
