MATLAB: How to change the center of rotation while using ROTATE3D icon in the figure window in MATLAB 7.4 (R2007a)

axiscenterfigureMATLABrotaterotate3drotation

I am trying to rotate a contour plot in 3D using the ROTATE3D icon in the figure window. I want to define the center of rotation for this so that my point of interest is in view in spite of all my rotation.

Best Answer

The center of rotation for the ROTATE3D function is always the center of the plot box, i.e. the center of the box defined by the X,Y and Z axes limits. Hence, you can change the axes limits using the AXIS command to make the point of interest the center of plot box.
t = 0:pi/50:10*pi;
plot3(sin(t),cos(t),t)
grid on
rotate3d on;
The above code will create a plot box with axis equal to [-1 1 -1 1 0 40] and with a rotation point located at the center of the box, i.e. (0,0,20). To change the rotation to (-1,-1,0), we use the AXIS command to set the box size such that the new rotation point is the center of the plot box:
axis([-3 1 -3 1 -40 40]);