# rotate

Rotate object about specified origin and direction

## Syntax

`rotate(h,direction,alpha)`

rotate(...,origin)

## Description

The `rotate`

function rotates a graphics object
in three-dimensional space.

`rotate(h,direction,alpha)`

rotates
the graphics object `h`

by `alpha`

degrees.
Specify `h`

as a surface, patch, line, text, or image
object. `direction`

is a two- or three-element vector
that describes the axis of rotation in conjunction with 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.

Positive `alpha`

is defined as the righthand-rule
angle about the direction vector as it extends from the origin of
rotation.

If `h`

is an array of handles, all objects
must be children of the same axes.

`rotate(...,origin)`

specifies
the origin of the axis of rotation as a three-element vector` [x`

. _{0},y_{0},z_{0}]

## Examples

## Tips

The rotation transformation modifies the object's data. This technique is different from that
used by `view`

and `rotate3d`

, which modify only the viewpoint.

The axis of rotation is defined by an origin of rotation and
a point `P`

. Specify `P`

as the
spherical coordinates `[theta phi]`

or as the Cartesian
coordinates ` [x`

._{p},y_{p},z_{p}]

In the two-element form for `direction`

, `theta`

is
the angle in the *x-y* plane counterclockwise from
the positive *x*-axis. `phi`

is
the elevation of the direction vector from the *x-y* plane.

The three-element form for `direction`

specifies
the axis direction using Cartesian coordinates. The direction vector
is the vector from the origin of rotation to `P`

.

## Tips

`rotate`

changes the values of the `Xdata`

, `Ydata`

,
and `Zdata`

properties to rotate graphics objects.

**Introduced before R2006a**