Jump to content

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

From Wikibooks, open books for an open world

gotolonglat

[edit | edit source]

gotolonglat { time <duration> distance <radiusdistance> up <upvector> longitude <longnumber> latitude <latnumber> }

Go to the currently selected object, taking <duration> seconds, stopping <radiusdistance> from the object, using <upvector> orientation, positioning yourself above the specified longitude <longnumber> and latitude <latnumber> surface coordinates.

Note: The gotolonglat command does not reset the coordinate system. It retains the previously set coordinate system.

Arguments:

time <duration>
The number of seconds to take going to the object. Default is 1.0 second.
distance <radiusdistance>
Describes how far away from the object you want to be positioned, in units of the object's radius, plus 1. Default is 5.0.
Special <distance> values are:
  • 0 (zero) is the center of the object.
    Note: In version 1.3.1, using this value causes the program to incorrectly recognize further positioning values, so do not use zero.
  • 1 is the surface of the object.
    Note: Traveling to the exact surface level of an object may cause some graphics cards to display random polygons on the display screen, so it is best to use a value slightly above the surface.
up <upvector>
Defines which axis points up, X [1 0 0], Y [0 1 0] or Z [0 0 1]. Default is [0 1 0].
longitude <longnumber>
This value describes the longitude surface coordinate you want to be positioned above, and should be specified as a decimal value in degrees. No default.
Longitude is specified as a negative number for the Western hemisphere and as a positive number for the Eastern hemisphere (“+” sign is not necessary).
latitude <latnumber>
This value describes the latidude surface coordinate you want to be positioned above, and should be specified as a decimal value in degrees. No default.
Latitude is specified as a negative number for the Southern hemisphere, and as a positive number for the Northern hemisphere (“+” sign is not necessary).


CELX equivalent:

Based on the observer:gotolonglat() method.

  • Find the target object with name <string> to go to and store in "objectname".
    In CELX scripting it is not necessary to select "objectname".
objectname = celestia:find( <string> )
  • Determine the radius of "objectname" and store in "radius".
radius = objectname:radius()
  • Determine distance in km to goto as: <radiusdistance> * "radius" and store in "distance".
distance = <radiusdistance> * radius
  • Convert <longnumber> and <latnumber> from degrees to radians by multiplying degrees with math.pi (= 3.14159265) and divide by 180. The Lua "math.rad()" function can also be used for this.
longitude = math.rad( <longnumber> )
latitude = math.rad( <latnumber> )
  • Define a vector object, to determine which axis points up.
upaxis = celestia:newvector( <upvector> )
  • Get observer instance of the active view and go to the "longitude" and "latitude" surface coordinates at the determined "distance" from the surface of "objectname" in <duration> seconds.
    • If no <duration> is given, the default time is 5.0 seconds !!!
    • If no <distance> is given, the default is 5 times the objects radius.
    • If no <longitude> is given, the default is 0.
    • If no <latitude> is given, the default is 0.
    • If no <upvector> is given, the default is (0,1,0) --> Y.
obs = celestia:getobserver()
obs:gotolonglat(objectname, longitude, latitude, distance, <duration>, upaxis )
  • Wait <duration> seconds.
wait( <duration> )

Summarized:

objectname = celestia:find( <string> )
radius = objectname:radius()
distance = <radiusdistance> * radius
longitude = math.rad( <longnumber> )
latitude = math.rad( <latnumber> )
upaxis = celestia:newvector( <upvector> )
obs = celestia:getobserver()
obs:gotolonglat(objectname, longitude, latitude, distance, <duration>, upaxis )
wait( <duration> )

Example:
This example selects the Earth and positions the camera over Seattle, Washington, USA.

CEL:

select      { object "Sol/Earth" }
synchronous { }
gotolonglat { time 5 distance 3 up [0 1 0] longitude -122 latitude 47 }
print       { text "Traveling to Seattle, Washington, USA."
              row -3 column 1 duration 5 }
wait        { duration 5 }
print       { text "Hovering over Seattle, Washington, USA."
              row -3 column 1 duration 5 }
wait        { duration 5 }

CELX with observer:gotolonglat() method:

earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs = celestia:getobserver()
obs:synchronous(earth)
earthradius = earth:radius()
earthdistance = 3 * earthradius
longitude = -122 * math.pi/180
latitude = 47 * math.pi/180
upaxis = celestia:newvector(0,1,0)
obs:gotolonglat(earth, longitude, latitude, earthdistance, 5.0, upvector)
celestia:print("Traveling to Seattle, Washington, USA.", 5.0, -1, -1, 1, 3)
wait(5.0)
celestia:print("Hovering over Seattle, Washington, USA.", 5.0, -1, -1, 1, 3)
wait(5.0)


Back to CEL command index