Rotate object about specified origin and direction
collapse all in page
Syntax
rotate(h,direction,angle)
rotate(h,direction,angle,origin)
Description
example
Note
hgtransform is recommended over rotate
because it provides better performance. Consider using hgtransform
unless you need to specify the origin of the axis of rotation.
rotate(h,direction,angle)
rotates the graphics object h
in the specified direction by the specified number of degrees. rotate
modifies the data of the graphics object, including the values of the Xdata
, Ydata
, and Zdata
properties. This behavior is different from that of view and rotate3d, which modify only the viewpoint.
example
rotate(h,direction,angle,origin)
specifies the origin of the axis of rotation. The default origin of the axis of rotation is the center of the plot box. This point is not necessarily the origin of the axes.
Examples
collapse all
Rotate Plot Around x-Axis
Open Live Script
Create a surface plot of the peaks
function and return the surface object.
s = surf(peaks(20));xlabel("x-axis")ylabel("y-axis")zlabel("z-axis")axis([0 20 0 20 -10 10])
Rotate the surface plot 25 degrees clockwise around its x-axis.
direction = [1 0 0];rotate(s,direction,25)
Rotate Plot Around x-Axis and y-Axis
Open Live Script
Create a surface plot of the peaks
function and return the surface object.
s = surf(peaks(20));xlabel("x-axis")ylabel("y-axis")zlabel("z-axis")axis([0 20 0 20 -10 10])
Rotate the surface plot 25 degrees clockwise around its x-axis and y-axis.
direction = [1 1 0];rotate(s,direction,25)
Rotate Plot Around Specified Origin
Open Live Script
Create a surface plot of the peaks
function and return the surface object.
s = surf(peaks(20));xlabel("x-axis")ylabel("y-axis")zlabel("z-axis")axis([0 20 0 20 -10 10])
Rotate the surface plot 30 degrees counterclockwise around its y-axis, and set the origin of rotation to (20, 10, 0).
s = surf(peaks(20));xlabel("x-axis")ylabel("y-axis")zlabel("z-axis")axis([0 20 0 20 -10 10])direction = [0 -1 0];origin = [20 10 0];rotate(s,direction,30,origin)
Input Arguments
collapse all
h
— Graphics object
single object | vector of objects
Graphics object, specified as a single object or a vector of objects of one of these types:
Surface
objectPatch
objectLine
objectText
object
If h
is a vector of objects, all objects must be children of the same axes.
Note
Image objects do not support 3-D data. Therefore, any rotation of an image out of the xy-plane is not supported.
direction
— Direction of axis of rotation
two-element vector of spherical coordinates | three-element vector of Cartesian coordinates
Direction of the axis of rotation, specified as a two-element vector of spherical coordinates ([theta phi]
) or a three-element vector of Cartesian coordinates ([x y z]
). Specify theta
and phi
in degrees.
For more information about specifying direction
, see Axis of Rotation.
Example: rotate(h,[1 0 0],25)
rotates the specified object clockwise around the x-axis.
Example: rotate(h,[90 0],25)
rotates the specified object clockwise around the y-axis.
angle
— Angle of rotation
scalar value in degrees
Angle of rotation, specified as a scalar value in degrees.
Example: rotate(h,[1 0 0],25)
rotates the specified object 25 degrees clockwise around the x-axis.
origin
— Origin of axis of rotation
three-element vector of Cartesian coordinates
Origin of the axis of rotation, specified as a three-element vector of Cartesian coordinates [x y z]
.
The default origin of the axis of rotation is the center of the plot box. This point is not necessarily the origin of the axes.
More About
collapse all
Axis of Rotation
The axis of rotation is defined by an origin of rotation and a direction vector or point P
. For the rotate
function, use the direction input argument to specify P
as the spherical coordinates [theta phi]
or as the Cartesian coordinates [x y z]
.
In the two-element form for direction
, 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 Cartesian coordinates of point P
. The axis of rotation follows the direction vector from the origin of rotation to P
.
Version History
Introduced before R2006a
See Also
hgtransform | view | rotate3d | sph2cart
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本 (日本語)
- 한국 (한국어)
Contact your local office