Jump to content

Celestia/Celx Scripting/CELX Lua Methods/CEL command setposition

From Wikibooks, open books for an open world

setposition

[edit | edit source]

setposition { base <basevector> offset <offsetvector> }

-- OR --

setposition { x <xbase64> y <ybase64> z <zbase64> }

Moves the camera to a specific position in the 3-dimensional universe. If you are attempting to duplicate a position based on a Bookmark or Cel://URL, you will also need to set the proper Coordinate System, orientation, and other parameters. (Also see seturl).

Arguments:

base <basevector>
Base vector [ <xnumber> <ynumber> <znumber> ]. No default.
This value may be obtained from a Celestia Bookmark, which is stored in the favorites.cel file located in the Celestia directory.
  • The 1st value <xnumber> represents the camera location, along the X axis in light-years.
  • The 2nd value <ynumber> represents the camera location, along the Y axis in light-years.
  • The 3rd value <znumber> represents the camera location, along the Z axis in light-years.
offset <offsetvector>
Offset value. No default.
This value may be obtained from a Celestia Bookmark, which is stored in the favorites.cel file located in the Celestia directory.
  • The 1st value <xoffsetnum> represents the offset of the camera location, with respect to the Base <basevector> along the X axis in light-years.
  • The 2nd value <yoffsetnum> represents the offset of the camera location, with respect to the Base <basevector> along the Y axis in light-years.
  • The 3rd value <zoffsetnum> represents the offset of the camera location, with respect to the Base <basevector> along the Z axis in light-years.

-- OR --

Arguments:

x <xbase64>
Represent the X-base and X-offset values as stored by a Cel://URL. No default.
It is obtained from the following Cel://URL value: ?x=.
y <ybase64>
Represent the Y-base and Y-offset values as stored by a Cel://URL. No default.
It is obtained from the following Cel://URL value: &y=.
z <zbase64>
Represent the Z-base and Z-offset values as stored by a Cel://URL. No default.
It is obtained from the following Cel://URL value: &z=.


CELX equivalent-1:

Based on parameter list-1 and the celestia:newposition(), celestia:newvector(), position:addvector() and observer:gotolocation() methods.

  • 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 light-year in a Celestia Bookmark to millionths of a light-year in a CELX position object.
pos = celestia:newposition( <xnumber> * 1e6, <ynumber> * 1e6, <znumber> * 1e6 )
  • Create new vector object from <xoffsetnum>, <yoffsetnum> and <zoffsetnum> and store in "vec". The units of the components of a vector object are millionths of a light-year, so you have to convert light-year in a Celestia Bookmark to millionths of a light-year in a CELX vector object.
vec = celestia:newvector( <xoffsetnum> * 1e6, <yoffsetnum> * 1e6, <zoffsetnum> * 1e6 )

  • Add new position object and new vector object and store in "tarpos".
tarpos = pos:addvector(vec)
  • Get observer instance of the active view and goto "tarpos" in zero seconds.
obs = celestia:getobserver()
obs:gotolocation(tarpos, 0.0 )

Note: In this equivalent, the observer goes to a position releative to the current frame of reference. If the current frame of reference is "universal", the observer:setposition() method may also be used instead of the observer:gotolocation() method.

Summarized:

pos = celestia:newposition( <xnumber> * 1e6, <ynumber> * 1e6, <znumber> * 1e6 )
vec = celestia:newvector( <xoffsetnum> * 1e6, <yoffsetnum> * 1e6, <zoffsetnum> * 1e6 )
tarpos = pos:addvector(vec)
obs = celestia:getobserver()
obs:gotolocation(tarpos, 0.0 )
wait(0.0)


CELX equivalent-2:

Based on parameter list-2 and the celestia:newposition(base64) and observer:gotolocation() methods.

  • 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-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=.
pos = celestia:newposition( <xbase64>, <ybase64>, <zbase64> )
  • Get observer instance of the active view and goto "pos" in zero seconds.
obs:gotolocation(pos, 0.0 )

Note: In this equivalent, the observer goes to a position releative to the current frame of reference. If the current frame of reference is "universal", the observer:setposition() method may also be used instead of the observer:gotolocation() method.

Summarized:

pos = celestia:newposition( <xbase64>, <ybase64>, <zbase64> )
obs = celestia:getobserver()
obs:gotolocation(pos, 0.0 )
wait(0.0)


Example-1:
Position the camera to a position in space outside of the Milky Way, according parameterlis-1:

CEL:

setposition { base [-64132.43  47355.11  196091.57] offset [ 0  0  -1.52e-005 ] }

CELX with the celestia:newposition(), celestia:newvector(), position:addvector() and observer:gotolocation() methods, based on parameter list-1:

pos = celestia:newposition( -64132.43 * 1e6, 47355.11 * 1e6 , 196091.57 * 1e6 )
vec = celestia:newvector( 0, 0, -1.52e-005 * 1e6 )
tarpos = pos:addvector(vec)
obs = celestia:getobserver()
obs:gotolocation(tarpos, 0.0)
wait(0.0)

-- OR -- (If current frame of reference is "universal")

pos = celestia:newposition( -64132.43 * 1e6, 47355.11 * 1e6 , 196091.57 * 1e6 )
vec = celestia:newvector( 0, 0, -1.52e-005 * 1e6 )
tarpos = pos:addvector(vec)
obs = celestia:getobserver()
obs:setposition(tarpos)
wait(0.0)


Example-2:
Position the camera to the same position in space outside of the Milky Way, according parameterlis-2.

Note: The CelURL values in this example are compatible with Celestia version 1.6.0.

CEL:

setposition { x "AMDCXoJK/3+IyGgR8f///w" y "BvP2LRdAAAD/n5UGCw" z "VUrGoeQJ+/8DyvenLQ" }

CELX with the celestia:newposition(base64) and observer:gotolocation() methods, based on parameter list-2:

pos = celestia:newposition("AMDCXoJK/3+IyGgR8f///w","BvP2LRdAAAD/n5UGCw","VUrGoeQJ+/8DyvenLQ" )
obs = celestia:getobserver()
obs:gotolocation(pos, 0.0)
wait(0.0)

-- OR -- (If current frame of reference is "universal")

pos = celestia:newposition("AMDCXoJK/3+IyGgR8f///w","BvP2LRdAAAD/n5UGCw","VUrGoeQJ+/8DyvenLQ" )
obs = celestia:getobserver()
obs:setposition(pos)
wait(0.0)


Back to CEL command index