Rotate object about a specified direction
Syntax
rotate(h,direction,alpha)
rotate(...,origin)
Description
The rotate
function rotates a graphics object in three-dimensional space, according to the right-hand rule.
rotate(h,direction,alpha)
rotates the graphics object h
by alpha
degrees.
direction
is a two- or three-element vector that describes the axis of rotation in conjunction with the origin.
rotate(...,origin)
specifies the origin of the axis of rotation as a three-element vector. The default is origin is the center of the plot box.
Remarks
The graphics object you want rotated must be a child of the same Axes. The object's data is modified by the rotation transformation. This is in contrast to view
and rotate3d
, which only modify the viewpoint.
The axis of rotation is defined by an origin and a point P relative to the origin. P is expressed as the spherical coordinates [theta phi]
, or as Cartesian coordinates.
The two-element form for direction
specifies the axis direction using the spherical coordinates [theta phi]
. theta
is the angle in the xy plane counterclockwise from the positive x-axis. phi
is the elevation of the direction vector from the xy plane.
The three-element form for direction
specifies the axis direction using Cartesian coordinates. The direction vector is the vector from the origin to (X,Y,Z).
Examples
Rotate a graphics object 180º about the x-axis:
h = surf(peaks(20));
rotate(h,[1 0 0],180)
Rotate a Surface graphics object 45º about its center in the z direction:
h = surf(peaks(20));
zdir = [0 0 1];
center = [10 10 0];
rotate(h,zdir,45,center)
Remarks
rotate
changes the Xdata
, Ydata
, and Zdata
properties of the appropriate graphics object.
See Also
rotate3d
, sph2cart
, view
The Axes CameraPosition
, CameraTarget
, CameraUpVector
, CameraViewAngle
[ Previous | Help Desk | Next ]