goto { time  distance  upframe  up  } Moves the camera to the currently selected object, taking  seconds, stopping  from the object (in units of object’s radius + 1), using the  Coordinate System, and defining the  axis that points up. Arguments: time  The number of seconds to take going to the object. Default is 1.0 second. distance  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  values are: 0 (zero) is the center of the object. 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. 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. upframe  Sets the specified Coordinate System. Default is "observer". The  must have one of the following values: chase ecliptical equatorial geographic lock observer universal up  Defines which axis points up, X [1 0 0], Y [0 1 0] or Z [0 0 1]. Default is [0 1 0]. CELX equivalent-1: Based on the observer:gotodistance() method. Find and select the target object with name  to go to and store in "objectname". objectname = celestia:find(  ) celestia:select(objectname) Get observer instance of the active view instance and set the coordinate system of the frame of reference to . obs = celestia:getobserver() frame = celestia:newframe( , objectname) obs:setframe(frame) Determine radius of "objectname" and store in "radius". radius = objectname:radius() Determine  as:  * "radius" of "objectname". distance =  * radius Define a vector object, to determine which axis points up. upaxis = celestia:newvector(  ) Goto determined  of "objectname" in  seconds with  pointing up. is the distance from the center of target where to stop in km. If no  is given, the default distance = 20000 km. If  is smaller than the radius of the object, the goto will end within the object !!! To obtain the radius of an object in km, you can use the object:radius() method. is the number of seconds the goto should take. If no  is given, the default time = 5.0 seconds !!! If no  = upaxis is given, the default is (0,1,0) --> Y-axis. obs:gotodistance(objectname, distance, , upaxis ) Wait  seconds. wait(  ) Summarized: objectname = celestia:find(  ) celestia:select(objectname) obs = celestia:getobserver() frame = celestia:newframe( , objectname) obs:setframe(frame) radius = objectname:radius() distance =  * radius upaxis = celestia:newvector(  ) obs:gotodistance(objectname, distance, , upaxis ) wait(  ) CELX equivalent-2: 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, so the axis that points up after the goto can also be determined. This method uses positions to goto, instead of a distance from the object, so that needs some additional calculations. 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: Find and select the target object with name  to go to and store in "objectname". objectname = celestia:find(  ) celestia:select(objectname) Get observer instance of the active view instance and set the coordinate system of the frame of reference to . obs = celestia:getobserver() frame = celestia:newframe( , objectname) obs:setframe(frame) Determine radius of “objectname” and store in “radius”. radius = objectname:radius() Determine distance in km to goto as:  * "radius" and store in "distance". distance =  * radius Convert the determined "distance" to "objectname" into positions as follows: uly_to_km = 9460730.4725808 –- Determine and store the current observer position frompos = obs:getposition() –- Determine and store the current position of objectname objectpos = objectname:getposition() –- Determine the vector between the current observer -- position and the current position of objectname distancevec = frompos:vectorto(objectpos) -– Determine the length of this vector in millionths of a light-year. distancelength = distancevec:length() –- Normalize this length to 1 normalvec = distancevec:normalize() –- Distance to travel = (distancelength - distance /uly_to_km) –- Direction to travel = normalvec travelvec = (distancelength - distance /uly_to_km)*normalvec -– Determine and store the position to goto topos = frompos + travelvec The target observer orientation must point from the target position “topos” towards "objectname" with  as up vector: upvec = celestia:newvector(  ) torot = topos:orientationto(objectpos, upvec) Define and initialize the parameter table as follows: Determine the number of seconds the goto should take. Obtain the current position of the observer. New position object = topos (result of 2 steps back). Obtain the current orientation of the observer. New observer orientation = torot (result of previous step). 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 parameters={} parameters.duration =  parameters.from = obs:getposition() parameters.to = topos parameters.initialOrientation = obs:getorientation() parameters.finalOrientation = torot parameters.startInterpolation = 0.2 parameters.endInterpolation = 0.8 parameters. accelTime = 0.1 Goto target position with target orientation in  seconds. obs:goto(parameters) Wait  seconds. wait(parameters.duration) Summarized: objectname = celestia:find(  ) celestia:select(objectname) obs = celestia:getobserver() frame = celestia:newframe( , objectname) obs:setframe(frame) radius = objectname:radius() distance =  * radius uly_to_km = 9460730.4725808 –- Determine and store the current observer position frompos = obs:getposition() –- Determine and store the current position of objectname objectpos = objectname:getposition() –- Determine the vector between the current observer -- position and the current position of objectname distancevec = frompos:vectorto(objectpos) -– Determine the length of this vector in millionths of a light-year. distancelength = distancevec:length() –- Normalize this length to 1 normalvec = distancevec:normalize() –- Distance to travel = (distancelength - distance /uly_to_km) –- Direction to travel = normalvec travelvec = (distancelength - distance /uly_to_km)*normalvec -– Determine and store the position to goto topos = frompos + travelvec upvec = celestia:newvector(  ) torot = topos:orientationto(objectpos, upvec) parameters={} parameters.duration =  parameters.from = obs:getposition() parameters.to = topos parameters.initialOrientation = obs:getorientation() parameters.finalOrientation = torot parameters.startInterpolation = 0.2 parameters.endInterpolation = 0.8 parameters. accelTime = 0.1 obs:goto(parameters) wait(parameters.duration) Example: The following example selects Mars and takes five seconds to travel 10 times the radius of mars above the surface and Y-axis pointing up. CEL: select { object "Mars" } goto { time 5.0 distance 11.0 upframe "ecliptic" up [0 1 0] } print { text "We're on our way to Mars." row -3 column 1 duration 5 } wait { duration 5 } CELX-1 with observer:gotodistance() method: mars = celestia:find("Sol/Mars") celestia:select(mars) frame = celestia:newframe("ecliptic", mars) obs = celestia:getobserver() obs:setframe(frame) marsradius = mars:radius() marsdistance = 11 * marsradius upaxis = celestia:newvector(0,1,0) obs:gotodistance(mars, marsdistance, 5.0, upaxis) celestia:print("We're on our way to Mars." , 5.0, -1, -1, 1, 3) wait(5.0) CELX-2 with observer:goto(table) method: mars = celestia:find("Sol/Mars") celestia:select(mars) frame = celestia:newframe("ecliptic", mars) obs = celestia:getobserver() obs:setframe(frame) marsradius = mars:radius() distance = 11 * marsradius uly_to_km = 9460730.4725808 frompos = obs:getposition() objectpos = mars:getposition() distancevec = frompos:vectorto(objectpos) distancelength = distancevec:length() normalvec = distancevec:normalize() travelvec = (distancelength - distance /uly_to_km)*normalvec topos = frompos + travelvec upvec = celestia:newvector(0,1,0) torot = topos:orientationto(objectpos, upvec) parameters={} parameters.duration = 5.0 parameters.from = obs:getposition() parameters.to = topos parameters.initialOrientation = obs:getorientation() parameters.finalOrientation = torot parameters.startInterpolation = 0.2 parameters.endInterpolation = 0.8 parameters. accelTime = 0.1 obs:goto(parameters) celestia:print("We're on our way to Mars." , 5.0, -1, -1, 1, 3) wait(parameters.duration) Back to CEL command index
{'wiki_source': 'wikibooks', 'other_info': "{'content_model': 'wikitext', 'language': 'en', 'title': 'Celestia/Celx Scripting/CELX Lua Methods/CEL command goto', 'type': 'text'}"}