# Celestia/Celx Scripting/CELX Lua Methods/CEL command rotate
### rotate

rotate { duration <duration> rate <rate> axis <axisvector> }
Rotates the camera using the currently defined Coordinate System during <duration> seconds. You must first use the select command to select an object, and optionally use the setframe command to set Coordinate System, if it is not currently defined.
The rotate command must be followed by a wait command with a <duration> equal to or greater than that of the rotate command.
Arguments:

#### duration <duration>

    The length of time, in seconds, to execute the rotate command. Default is 1.0 second.

#### rate <rate>

    Speed at which to rotate the camera. Default is 0.0. Positive and negative values are used to indicate the direction of rotation.

#### axis <axisvector>

    Defines which axis [ <x> <y> <z> ] to rotate around. No default. Set the <x> , <y> or <z> value to 1 for yes, 0 for no. You may also specify multiple axes.
CELX equivalent-1:
Based on the observer:rotate method.
This equivalent rotates the observer during about <duration> seconds over exactly <duration> * <rate> degrees.
* Find and select an object with name <string> to select and store in "objectname".
* Initialize "duration" of the rotation in seconds.
* Calculate "rotationangle" as the product of "duration" * <rate> in units of degrees. <rate> is the rotation velocity in degrees per second. The "rotationangle" must be converted to radians by multiplying with math.pi (= 3.14159265) and divide by 180. The Lua math.rad(rotationangle) function can also be used for this.
* Create the axis vector [ <x> <y> <z> ] for the rotation and store in "axis_vector".
* Get observer instance of the active view and store in "obs".
* Split up the rotation in 50 steps per second. The factor 0.75 is an estimate and may depend on the speed of your computer.
* Create new rotation object of split up rotation angle over the specified axis.
* Actually execute the rotation.
Summarized:
Summarized as a function:
CELX equivalent-2:
Based on the observer:rotate method.
This equivalent rotates the observer during exactly <duration> seconds over about <duration> * <rate> degrees.
* Find and select an object with name <string> to select and store in "objectname".
* Initialize "duration" of the rotation in seconds.
* Calculate "rotationangle" as the product of "duration" * <rate> in units of degrees. <rate> is the rotation velocity in degrees per second. The "rotationangle" must be converted to radians by multiplying with math.pi (= 3.14159265) and divide by 180. The Lua math.rad(rotationangle) function can also be used for this.
* Create the axis vector [ <x> <y> <z> ] for the rotation and store in "axis_vector".
* Get observer instance of the active view and store in "obs".
* Split up the rotation in 50 steps per second. The factor 0.75 is an estimate and may depend on the speed of your computer.
* Create new rotation object of split up rotation angle over the specified axis.
* Get the elapsed time in seconds since the script has been started and store in "t0".
* Actually execute the rotation.
Summarized:
Summarized as a function:
Example: The following example selects, follows and centers Earth (so the coordinate system of the frame of reference is set to ecliptic), then rotates the camera to the right (positive rate value) along the Z axis of the currently selected object for 5 seconds.
CEL:
CELX with the observer:rotate method, exact angle:
CELX with the observer:rotate method in a function, exact angle:
CELX with the observer:rotate method, exact time:
CELX with the observer:rotate method in a function, exact time:
Back to CEL command index