You must do two things in order to avoid seeing a "bouncing" affect as you rotate around a 3-D image.
1. Set 'CameraViewAngleMode' to 'Manual'
The 'CameraViewAngle' property determines the camera field of view. Changing this value affects the size of graphics objects displayed in the axes. By default, the 'CameraViewAngleMode' is set to 'Auto' so that MATLAB adjusts the view angle automatically. Setting 'CameraViewAngleMode' to 'Manual' prevents any unexpected adjustments. You can set this mode to manual with the following command:
set(axes_handle,'CameraViewAngleMode','Manual')
where "axes_handle" is the handle to axes (usually obtained by using the GCA command).
2. Setting the axes aspect ratio to 1.
Set the axes aspect ratio to [1 1] so that equal tick mark increments on the x-,y- and z-axis are equal in size. You can do this with the command:
This step is very important in order to properly rotate around your image. As the camera moves through your coordinate system, it is important that each tick have equal value. If the tick marks in one direction are much larger than the tick marks in another direction, then the camera will appear to zoom in and out as it changes axis alignments.
The following code domonstrates how these two steps produce a smoothly rotating animation.
figure('renderer','zbuffer','color','k')
[x,y,z]=sphere;
hold on
for j=[-1 1],
patch([-1 -1 1 1],[-1 1 1 -1],[j j j j],'b')
patch([-1 -1 1 1],[j j j j],[-1 1 1 -1],'r')
patch([j j j j],[-1 -1 1 1],[-1 1 1 -1],'g')
surf(x+3*j,y,z)
surf(x,y+3*j,z)
end
axis([-5 5 -6 6 -5 5],'off')
view(3)
[az,el]=view;
el=el+15;
set(gca,'cameraviewanglemode','manual')
axis equal
for j=10:10:360,
view(az+j,el)
pause(0.1)
end
Best Answer