example1

Demos rotation and scaling

clf
% Set the limits and select a view
ax = axes('XLim',[-1.5 1.5],'YLim',[-1.5 1.5],'ZLim',[-1.5 1.5]);
view(3); grid on; axis equal

% Create objects to group
[x y z] = cylinder([.2 0]);
h(1) = surface(x,y,z,'FaceColor','red');
h(2) = surface(x,y,-z,'FaceColor','green');
h(3) = surface(z,x,y,'FaceColor','blue');
h(4) = surface(-z,x,y,'FaceColor','cyan');
h(5) = surface(y,z,x,'FaceColor','yellow');
h(6) = surface(y,-z,x,'FaceColor','magenta');
set(h,'Clipping','off')

% Create group object and parent surfaces
t = hgtransform('Parent',ax);
set(h,'Parent',t)

mov = avifile('example1a.avi','fps',5);

% Set the renderer to OpenGL and update the display
set(gcf,'Renderer','opengl')
set(gcf,'Color','w');
drawnow;

% Rotate 360 degrees (2*pi radians)
radians_degree = pi/180;
for k = 60:6:360
    r = k*radians_degree;
    % z-axis rotation matrix
    Rz = makehgtform('zrotate',r);
    % scaling matrix
    Sxy = makehgtform('scale',r/4);

    % Concatenate the transforms and
    % set the transform Matrix property
    set(t,'Matrix',Rz*Sxy)
    drawnow
    F = getframe(gcf);
    mov = addframe(mov,F);
end
mov = close(mov);
% Reset to the original orientation and size using the identity matrix
set(t,'Matrix',eye(4))
Warning: Cannot locate Indeo5 compressor, using 'None' as the compression type.
See <a href="http://www.mathworks.com/support/solutions/data/1-4G50RI.html">Mathworks
Technical Solution 1-4G50RI</a> for more information.