MATLAB: How to rotate an axis about an arbitrary point in MATLAB 7.10 (R2010a)

arbitraryaxisfigureMATLABpointrotate

MATLAB’s ‘Rotate 3D’ icon rotates an axis about its center. However, I would like to rotate an axis about an arbitrarily defined point.

Best Answer

To rotate an axis about an arbitrary point in MATLAB 7.10 (R2010a), first set the Axis’ CameraTarget property to the desired center of rotation. Then use the Camera Toolbar’s ‘Orbit Camera’ icon (located on the left end of the Camera Toolbar) to interactively rotate the axis. For an example, please refer to the sample code below:
%create a sample Figure to work with
mesh(peaks)
%define an arbitrary center of rotation and plot it
CenterOfRotation = [10,10,0]
hold on
plot3(CenterOfRotation(1),CenterOfRotation(2),...
CenterOfRotation(3),'o')
%Set the Camera's target to the specified center of rotation
set(gca,'CameraTarget',CenterOfRotation)
%Open the Camera Toolbar
CameraToolbar