Jump to content

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

From Wikibooks, open books for an open world

setorientation

[edit | edit source]

setorientation { angle <anglenumber> axis <axisvector> }

-- OR --

setorientation { ow <ownumber> ox <oxnumber> oy <oynumber> oz <oznumber> }

Sets the camera orientation. 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, position, and other parameters.

Arguments:

angle <anglenumber>
Angle in degrees. No default.
This value may be obtained from a Celestia Bookmark, which is stored in the favorites.cel located in the Celestia directory.
axis <axisvector>
Rotation vector [ <xrot> <yrot> <zrot> ], no default.
This value may be obtained from a Celestia Bookmark, which is stored in the favorites.cel file located in the Celestia directory.
<xrot>, <yrot> and <zrot> are the Eular Angle or Angle-Axis representation of the camera's orientation. Think of them as Pitch, Yaw, and Roll in aviation.

-- OR --

Arguments:

ow <ownumber>
represents the angle as stored by a Cel://URL. It is obtained from the following Cel://URL value: &ow. No default.
ox <oxnumber>
represents the x-axis as stored by a Cel://URL. It is obtained from the following Cel://URL value: &ox=. No default.
oy <oynumber>
represents the y-axis as stored by a Cel://URL. It is obtained from the following Cel://URL value: &oy=. No default.
oz <oznumber>
represents the z-axis as stored by a Cel://URL. It is obtained from the following Cel://URL values: &oz=. No default.


CELX equivalent-1:

Based on Parameter list-1 and the celestia:newvector(), celestia:newrotation(axis-angle) and observer:setorientation() methods.

  • Create new vector, containing the axis of this rotation [ <xrot> , <yrot> , <zrot> ], and store in "vec".
vec = celestia:newvector( <xrot>, <yrot>, <zrot> )
  • Convert the <anglenumber> from degrees in radians and store in "angle":
    "angle" = math.pi / 180 * <anglenumber> (= 3.14159265 / 180 * <anglenumber> ).
    The Lua math.rad( <anglenumber> ) function can also be used for this.
angle = math.rad( <anglenumber> )
  • Create new rotation (i.e. a quaternion) of an "angle" about the specified axis of this rotation in "vec", and store in "rot".
rot = celestia:newrotation(vec, angle)
  • Get observer instance of the active view and rotate the observer according the created new rotation in "rot".
obs = celestia:getobserver()
obs:setorientation(rot)

Summarized:

vec = celestia:newvector( <xrot>, <yrot>, <zrot> )
angle = math.rad( <anglenumber> )
rot = celestia:newrotation(vec, angle)
obs = celestia:getobserver()
obs:setorientation(rot)


CELX equivalent-2:

Based on Parameter list-2 and the celestia:newrotation() and observer:setorientation() methods.

  • Create new rotation (i.e. a quaternion) from four scalar values and store in rot.
    <ownumber>: The OW-component of the new rotation, as a number-values taken from a cel-style URL &ow=.
    <oxnumber>: The OX-component of the new rotation, as a number-values taken from a cel-style URL &ox=.
    <oynumber>: The OY-component of the new rotation, as a number-values taken from a cel-style URL &oy=.
    <oznumber>: The OZ-component of the new rotation, as a number-values taken from a cel-style URL &oz=.
rot = celestia:newrotation( <ownumber>, <oxnumber>, <oynumber>, <oznumber> )
  • Get observer instance of the active view and rotate the observer according the created new rotation in "rot".
obs = celestia:getobserver()
obs:setorientation(rot)

Summarized:

rot = celestia:newrotation( <ownumber>, <oxnumber>, <oynumber>, <oznumber> )
obs = celestia:getobserver()
obs:setorientation(rot)

Example:
Set the camera orientation according parameterlist-1:

CEL:

setorientation { angle 0.945208 axis [ 0.81466 -0.570975 -0.101573 ] }

CELX based on parameter list-1:

vec = celestia:newvector(0.81466, -0.570975, -0.101573)
angle = math.rad(0.945208)
rot = celestia:newrotation(vec, angle)
obs = celestia:getobserver()
obs:setorientation(rot)

Example:
Set the camera orientation according parameterlist-2:

CEL

setorientation { ow 0.090610 ox -0.494683 oy 0.860207 oz -0.084397 }

CELX based on parameter list-2:

rot = celestia:newrotation(0.090610, -0.494683, 0.860207, -0.084397)
obs = celestia:getobserver()
obs:setorientation(rot)


Back to CEL command index