Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

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

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

move move { duration <duration> velocity <vector> } Move the camera at the specified <vector> velocity in km/sec for each of the X, Y and Z axes, for the specified <duration> in seconds.A wait command is not necessary after a move command. duration <duration> Number of seconds to take during the move. No default. velocity <vector> Speed as defined for the currently active coordinate system, in km/second for each of the X, Y and Z axes in a vector [ < xspeed > < yspeed > < zspeed > ]. No default.Positive and negative <vector> values are used to indicate forward and reverse respectively ("+" sign is not necessary for positive values). CELX equivalent: Based on the observer:goto(table) method. Note: The given positions in the observer:goto(table) method 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. In CELX, positions are stored in millionths of a light year, so you have to convert km to millionths of a light year, using the "uly_to_km" constant. uly_to_km = 9460730.4725808 Obtain observer instance of the active view and store in "obs". obs = celestia:getobserver() Determine the actual observer position and store in "frompos": frompos = obs:getposition() Determine the position to goto as follows: Convert vector [ <xspeed> <yspeed> <zspeed> ] to millionths of a light year and store in "velocityvector". Multiply "velocityvector" with <duration> seconds and add the result to the actual server position. The result must be stored in "topos". velocityvector = celestia:newvector( <xspeed>/uly_to_km, <yspeed>/uly_to_km, <zspeed>/uly_to_km) topos = frompos + <duration> * velocityvector Define and initialize the parameter table as follows: Determine the number of seconds the goto should take. Obtain the current position of the observer = frompos (obtained 2 steps ago). New position object = topos (obtained in previous step)) Obtain the current orientation of the observer. Because CEL: move does not change the observer orientation, the final orientation is the same as the initial orientation. Start adjusting the observer orientation after 0 percent of the time to goto (it’s the same orientation) End adjusting the observer orientation after 0 percent of the time to goto (it’s the same orientation). Spend 10% of the time for accelerating and decelerating parameters={} parameters.duration = <duration> parameters.from = frompos parameters.to = topos parameters.initialOrientation = obs:getorientation() orientation.parameters.finalOrientation = parameters.initialOrientation parameters.startInterpolation = 0 parameters.endInterpolation = 0 parameters.accelTime = 0.1 Move the observer <duration> seconds towards target position. obs:goto(parameters) Wait <duration> seconds. wait(parameters.duration) Summarized: uly_to_km = 9460730.4725808 obs = celestia:getobserver() frompos = obs:getposition() velocityvector = celestia:newvector( <xspeed>/uly_to_km, <yspeed>/uly_to_km, <zspeed>/uly_to_km) topos = frompos + <duration> * velocityvector parameters = { } parameters.duration = <duration> parameters.from = frompos parameters.to = topos parameters.initialOrientation = obs:getorientation() parameters.finalOrientation = parameters.initialOrientation parameters.startInterpolation = 0 parameters.endInterpolation = 0 parameters.accelTime = 0.1 obs:goto(parameters) wait(parameters.duration) Summarized as a function: function move_obs(time, x, y, z) local uly_to_km = 9460730.4725808 local obs = celestia:getobserver() local parameters = { } parameters.duration = time parameters.from = obs:getposition() local vector = celestia:newvector(x/uly_to_km, y/uly_to_km, z/uly_to_km) parameters.to = parameters.from + parameters.duration * vector parameters.initialOrientation = obs:getorientation() parameters.finalOrientation = parameters.initialOrientation parameters.startInterpolation = 0 parameters.endInterpolation = 0 parameters.accelTime = 0.1 obs:goto(parameters) wait(time) end move_obs( <duration>, <xspeed>, <yspeed>, <zspeed> ) Example:This example selects the Earth and positions the camera over Seattle, Washington, USA.Then moves the camera for 10 seconds as follows: along the X axis at a speed of 1000 km/second. along the Y axis at a speed of 2000 km/second. along the Z axis at a speed of 1500 km/second. 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 } move { duration 10 velocity [ 500 1000 750 ] } CELX with the observer:goto(table) 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 obs:gotolonglat(earth, longitude, latitude, earthdistance, 5.0) celestia:print("Traveling to Seattle, Washington, USA.", 5.0, -1, -1, 1, 3) wait(5.0) uly_to_km = 9460730.4725808 obs = celestia:getobserver() frompos = obs:getposition() velocityvector = celestia:newvector( 500/uly_to_km, 1000/uly_to_km, 750/uly_to_km) topos = frompos + 10 * velocityvector parameters = { } parameters.duration = 10 parameters.from = frompos parameters.to = topos parameters.initialOrientation = obs:getorientation() parameters.finalOrientation = parameters.initialOrientation parameters.startInterpolation = 0 parameters.endInterpolation = 0 parameters.accelTime = 0.1 obs:goto(parameters) wait(parameters.duration) CELX with the observer:goto(table) method in a function: function move_obs(time, x, y, z) local obs = celestia:getobserver() local uly_to_km = 9460730.4725808 local parameters = { } parameters.duration = time parameters.from = obs:getposition() local vector = celestia:newvector(x/uly_to_km, y/uly_to_km, z/uly_to_km) parameters.to = parameters.from + parameters.duration * vector parameters.initialOrientation = obs:getorientation() parameters.finalOrientation = parameters.initialOrientation parameters.startInterpolation = 0 parameters.endInterpolation = 0 parameters.accelTime = 0.1 obs:goto(parameters) wait(time) end 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 obs:gotolonglat(earth, longitude, latitude, earthdistance, 5.0) celestia:print("Traveling to Seattle, Washington, USA.", 5.0, -1, -1, 1, 3) wait(5.0) move_obs(10, 500, 1000, 750) Back to CEL command index