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

gotoloc { time <duration> position <vector> xrot <xrot> yrot <yrot> zrot <zrot> }
-- OR --
gotoloc { time <duration> x <xbase64> y <ybase64> z <zbase64> ow <ownumber> ox <oxnumber> oy <oynumber> oz <oznumber> }
Move the camera to the currently selected object, taking <duration> seconds, traveling to the specified position (or the Base64 values x, y, and z from a Cell://URL), using the orientation specified via xrot, yrot, and zrot (or ow, ox, oy, and oz).
Arguments:

#### time <duration>

    Number of seconds to take centering the object. Default is 1.0 second.

#### position <vector>

    Defines a point in the current Coordinate System specified in units of kilometers. Default is [0 1 0]. For all but the universal Coordinate System, a position of [ 0 0 0 ] is the center of the object The kilometer value you specify must include the radius of the object.
   * The 1st value <xnumber> represents the camera location, in kilometers, along the X axis.
   * The 2nd value <ynumber> represents the camera location, in kilometers, along the Y axis.
   * The 3rd value <znumber> represents the camera location, in kilometers, along the Z axis.

#### xrot <xrot>

    The "Eular Angle" or "Angle-Axis" representation of the camera's orientation in degrees. Default is 0. Think of it as Pitch in aviation.

#### yrot <yrot>

    The "Eular Angle" or "Angle-Axis" representation of the camera's orientation in degrees. Default is 0. Think of it as Yaw in aviation.

#### zrot <zrot>

    The "Eular Angle" or "Angle-Axis" representation of the camera's orientation in degrees. Default is 0. Think of it as Roll in aviation.
-- OR --
Arguments:

#### time <duration>

    Number of seconds to take centering the object. No default.

#### x <xbase64>

    This value represents the X position as stored by a CelURL. No default. The value can be obtained from the CelURL value after: ?x=

#### y <ybase64>

    This value represents the Y position as stored by a CelURL. No default. The value can be obtained from the CelURL value after: &y=

#### z <zbase64>

    This value represents the Z position as stored by a CelURL. No default. The value can be obtained from the CelURL value after: &z=

#### ow <ownumber>

    This value represents the OW orientation as stored by a CelURL. No default. The value can be obtained from the CelURL value after: &ow=

#### ox <oxnumber>

    This value represents the OW orientation as stored by a CelURL. No default. The value can be obtained from the CelURL value after: &ox=

#### oy <oynumber>

    This value represents the OW orientation as stored by a CelURL. No default. The value can be obtained from the CelURL value after: &oy=

#### oz <oznumber>

    This value represents the OW orientation as stored by a CelURL. No default. The value can be obtained from the CelURL value after: &oz=
CELX equivalent-1:
Based on Parameter list-1 and the observer:setorientation and observer:gotolocation methods.
Note: The disadvantage of this combination of methods is the sequential execution of these methods and the new observer orientation is set at once instead of smoothly during the goto.
* Create new position object from <xnumber>, <ynumber> and <znumber> and store in "pos". The units of the components of a position object are millionths of a light-year, so you have to convert km to millionths of a light year, using the "uly_to_km" constant.
* Specify and create the axis of this rotation [ <xrot> , <yrot> , <zrot> ] and store it in "vec". <xrot> , <yrot> and <zrot> are the "Eular Angle" or "Angle-Axis" representation of the camera's orientation in degrees. Think of them as Pitch, Yaw, and Roll in aviation.
* Create new rotation (i.e. a quaternion) about the specified axis and store in "rot". "angle" = math.pi / 180 (= 3.14159265 / 180), to obtain radians out of degrees.
* Get observer instance of the active view instance and rotate the observer according the created new rotation "rot".
* Go to target position "pos" in <duration> seconds.
* Wait <duration> seconds.
Summarized:
CELX equivalent-2:
Based on Parameter list-2 and the observer:setorientation and observer:gotolocation methods.
Note: The disadvantage of this combination of methods is the sequential execution of these methods and the new observer orientation is set at once instead of smoothly during the goto.
* Create new position object from URL-style Base64-encoded values and store in "pos". <xbase64>: The X-component of the new vector, as a string-value taken from a cel-style URL ?x=. <ybase64>: The Y-component of the new vector, as a string-value taken from a cel-style URL &y=. <zbase64>: The Z-component of the new vector, as a string-value taken from a cel-style URL &z=.
* Create new rotation (i.e. a quaternion) from four scalar values (the values used in a CEL://URL), and store in "rot". <ownumber>: The OW-component of the new rotation, as a number-value taken from a cel-style URL &ow=. <oxnumber>: The OX-component of the new rotation, as a number-value taken from a cel-style URL &ox=. <oynumber>: The OY-component of the new rotation, as a number-value taken from a cel-style URL &oy=. <oznumber>: The OZ-component of the new rotation, as a number-value taken from a cel-style URL &oz=.
* Get observer instance of the active view and rotate the observer according the created new rotation "rot".
* Go to target position “pos” in <duration> seconds.
* Wait <duration> seconds.
Summarized:
CELX equivalent-3:
Based on the observer:goto(table) method.
Using this method, many different types of gotos can be performed. The strength of this method is that the observer orientation can be programmed and interpolated, so the orientation of the observer can be changed during the goto.
This method uses position objects to goto and rotation objects to set the observer orientation. Both positions and rotations can be extracted from Parameter list-1 and Parameter list-2 arguments. The parameters for the goto must be given in the table:
** parameters.duration: duration (number)
** parameters.from: source position
** parameters.to: target position
** parameters.initialOrientation: source orientation
** parameters.finalOrientation: target orientation
** parameters.startInterpolation:
** parameters.endInterpolation:
** parameters.accelTime:
* Get observer instance of the active view and store in "obs".
* Define and initialize the parameter table as follows:
** Determine the number of seconds the goto should take.
** Obtain the current position of the observer.
** Create new position object. There are 2 possibilities regarding the originally used CEL parameterlist:
*** from <xnumber>, <ynumber> and <znumber> and store in "parameters.to". The units of the components of a position object are millionths of a light-year, so you have to convert km to millionths of a light year, using “uly_to_km”. Note: The given positions are expected to be relative to the universal frame-of-reference, while the non table-based goto uses positions relative to the current frame-of-reference. So depending on the used frame of reference, you have to convert the position first to universal!
*** from URL-style Base64-encoded values and store in "parameters.to": <xbase64>: The X-component of the new vector, as a string-values taken from a cel-style URL ?x=. <ybase64>: The Y-component of the new vector, as a string-values taken from a cel-style URL &y=. <zbase64>: The Z-component of the new vector, as a string-values taken from a cel-style URL &z=.
** Obtain the current orientation of the observer.
** Create new rotation object. There are 2 possibilities regarding the originally used CEL parameterlist:
*** Specify and create the axis of the observer rotation [<xrot> , <yrot> , <zrot> ] and store it in "vec". <xrot> , <yrot> and <zrot> are the "Eular Angle" or "Angle-Axis" representation of the observer orientation in degrees. Think of them as Pitch, Yaw, and Roll in aviation. Then create new rotation (i.e. a quaternion) about the specified axis and use "angle" = math.pi/180 (= 3.14159265 / 180), to obtain radians out of degrees. Store this new rotation in "parameters.finalOrientation".
*** from four scalar values (the values used in a CEL://URL), and store in "parameters.finalOrientation". <ownumber>: The OW-component of the new rotation, as a number-value taken from a cel-style URL &ow=. <oxnumber>: The OX-component of the new rotation, as a number-value taken from a cel-style URL &ox=. <oynumber>: The OY-component of the new rotation, as a number-value taken from a cel-style URL &oy=. <oznumber>: The OZ-component of the new rotation, as a number-value taken from a cel-style URL &oz=.
** Start adjusting the observer orientation after 20 percent of the time to goto.
** End adjusting the observer orientation after 80 percent of the time to goto.
** Spend 10% of the time for accelerating and decelerating
-- OR --
* Goto target position with target orientation in <duration> seconds.
* Wait <duration> seconds.
Summarized:
-- OR --
-- OR --
Example: The next example demonstrates both gotoloc methods. It travels to the Earth, setting a position so you can see the night lights over the USA, view the Sun in the upper left hand corner of the display, and the Moon in the upper right hand corner.
Note: The lines of code starting with "#" (CEL) and "--" (CELX) are comment lines for further explanation:
Note: The CelURL values in this example are compatible with Celestia version 1.6.0.
CEL:
CELX-1 with observer:gotolocation method:
CELX-2 with observer:goto(table) method:
Back to CEL command index