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

orbit { duration <duration> rate <rate> axis <axisvector> }
Orbit the currently selected object during <duration> seconds at <rate> speed (in units of degrees per second), using the currently defined Coordinate System, around the specified <axisvector>. You must first use the select command to select an object, and optionally use the setframe command to define a Coordinate System, if one is not currently defined.
Arguments:

#### duration <duration>

    Number of seconds to orbit the object. Default is 1.0.

#### rate <rate>

    Speed at which to orbit the object, in units of degrees per second. Default is 1.0. Positive and negative values are used to indicate the direction of orbit ("+" sign is not necessary).

#### axis <axisvector>

    Define which axis to orbit around [x y z]. 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 for Celestia version 1.6.1 and later:
Based on the 1.6.1 observer:orbit method.
This equivalent orbits the reference object during about <duration> seconds over exactly <duration> * <rate> degrees.
* Find and select the object with name <string> that must be orbited and store in "objectname".
* Get observer instance of the active view and store in "obs".
* Make "objectname" the reference object in the "ecliptic" (follow) frame of reference.
* "duration" = <duration> = the duration of the orbit in seconds.
* <rate> is the orbit velocity in degrees per second, which must be transformed in radians per second by multiplying the <rate> with math.pi (= 3.14159265) and divide by 180 and stored in "radiansrate". The Lua math.rad( <rate> ) function can also be used for this.
* Create a vector <axisvector> for the axis to orbit around.
* Determine the orbit angle in radians by multiplying <duration> with "radiansrate".
* Split up the orbit in 30 steps per second and determine the orbit steptime for each single step. The factor 0.75 is an estimate and may depend on the speed of your computer.
* Create new rotation object of split up orbit angle around the specified axis.
* Actually execute the orbit.
Summarized:
Summarized as a function:
CELX equivalent-2 for Celestia version 1.6.1 and later:
Based on the 1.6.1 observer:orbit method.
This equivalent orbits the reference object during exacly <duration> seconds over about <duration> * <rate> degrees.
* Find and select the object with name <string> that must be orbited and store in "objectname".
* Get observer instance of the active view and store in "obs".
* Make "objectname" the reference object in the "ecliptic" (follow) frame of reference.
* "duration" = <duration> = the duration of the orbit in seconds.
* <rate> is the orbit velocity in degrees per second, which must be transformed in radians per second by multiplying the <rate> with math.pi (= 3.14159265) and divide by 180 and stored in "radiansrate". The Lua math.rad( <rate> ) function can also be used for this.
* Determine the orbit angle in radians by multiplying <duration> with "radiansrate".
* Create a vector <axisvector> for the axis to orbit around.
* Split up the orbit in 30 steps per second and determine the orbit steptime for each single step. The factor 0.75 is an estimate and may depend on the speed of your computer.
* Create new rotation object of split up orbit angle around the specified axis.
* Get the elapsed time in seconds since the script has been started and store in "t0".
* Actually execute the orbit.
Summarized:
Summarized as a function:
CELX equivalent-3:
Based on an arithmetic sequence of methods.
Note: NO <axisvector> can be defined in this CELX equivalent.
* Find and select the object with name <string> that must be orbited and store in "objectname".
* "duration" = <duration> = the duration of the orbit in seconds.
* <rate> is the orbit velocity in degrees per second, which must be transformed in radians per second by multiplying the <rate> with math.pi (= 3.14159265) and divide by 180 and stored in "radiansrate". The Lua math.rad( <rate> ) function can also be used for this.
* Get observer instance of the active view and store in "obs".
* "v1" is the vector from the viewer to "objectname", normalized to length 1. "up" is the camera up direction (standard Y-direction). "v2" is normal to both "v1" and "up", normalized to length 1.
* Determine the orbit angle in radians by multiplying <duration> with "radiansrate".
* Orbit in the plane containing "v1" and normal to the up direction in <duration> seconds
Summarized:
Summarized as a function:
Example: The following example orbits Saturn for 12 seconds.
CEL:
CELX with the 1.6.1 observer:orbit method:
This equivalent orbits the reference object during about 12 seconds over exactly 12 * 30 = 360 degrees.
CELX with the 1.6.1 observer:orbit method in a function:
This equivalent orbits the reference object during about 12 seconds over exactly 12 * 30 = 360 degrees.
CELX with the 1.6.1 observer:orbit method:
This equivalent orbits the reference object during exacly 12 seconds over about 12 * 30 = 360 degrees.
CELX with the 1.6.1 observer:orbit method in a function:
This equivalent orbits the reference object during exacly 12 seconds over about 12 * 30 = 360 degrees.
CELX with an arithmetic sequence of methods:
CELX with an arithmetic sequence of methods in a function:
Back to CEL command index