MATLAB Functions | Help Desk |
rotate
Rotate object about a specified directionrotate(h,direction,alpha) rotate(...,origin)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 [0 0 0]
.
The graphics object you want rotated must be a child of an Axes graphics object. 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.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.direction
specifies the axis direction using Cartesian coordinates. The direction vector is the vector from the origin to (X,Y,Z).
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)
rotate
changes the Xdata
, Ydata
, and Zdata
properties of the appropriate graphics object.
rotate3d
, sph2cart
, view