ScriptedOrbit tutorial

All tutorials about Celestia go in here. For Celestia itself, add-ons, textures, scripting, etc.

Moderator: selden

Re: Three Lissajous curves

Postby Fenerit » Sun Oct 11, 2009 7:37 am

These two curves could be useful for Celestia Sci-fi users. They simulate a motion saw often in the Sci-fi movies: the dock bay approach. Usually a spacecraft escape from iperspace at high velocity for then accomplish a slowly approach to the bay. Or, it lift off the bay with slow velocity for then jump into iperspace.

Paste this code in the scriptorbit.ssc:
Code: Select all
"Scifi_docks X" "Sol/Eros"
{

   Class "spacecraft"
    Radius 1

   Color [ 1 0 1 ]

   OrbitFrame { BodyFixed { Center "Sol/Eros" } }
    BodyFrame { BodyFixed { Center "Sol/Eros" } }
   
   ScriptedOrbit
    {
        Module "scifi_docks"
        Function "scifi_docks"

        PeriodX       0.000025      
        PeriodY       0.000025      
        PeriodZ       0.000025
        PhaseX          0.25      
        PhaseY          0.25         
        PhaseZ          0.0         
        AmplitudeX       25         
        AmplitudeY       25         
        AmplitudeZ       0.0         
    }

   
}


Then paste the text below in a editor and save it as scifi_docks.lua module in the ../celxx/ dir:

Code: Select all
function scifi_docks(t)
   -- Create a new table
   local orbit = {};

   -- Save the parameter list
   orbit.params = t;

   -- Set the required fields boundingRadius and position; note that position is actually a function

   -- Compute the bounding radius from the amplitudes
   orbit.boundingRadius =
       math.sqrt(t.AmplitudeX * t.AmplitudeX +
                 t.AmplitudeY * t.AmplitudeY +
                 t.AmplitudeZ * t.AmplitudeZ)

   -- The position function will be called whenever Celestia needs the position of the object
   function orbit:position(tjd)
       local t = tjd - 2451545.0
       local pi2 = math.pi * 2;
      
   -- Bay approach --

      local x = self.params.AmplitudeX * math.exp (1 / math.tan((t / self.params.PeriodX - self.params.PhaseX)))
       local y = self.params.AmplitudeY * math.exp (1 / math.tan((t / self.params.PeriodY - self.params.PhaseY)))
       local z = self.params.AmplitudeZ * math.exp (1 / math.tan((t / self.params.PeriodZ - self.params.PhaseZ)))

   -- Bay escape -- comment the formers and uncomment the follows --

--     local x = self.params.AmplitudeX * math.exp (math.tan((t / self.params.PeriodX + self.params.PhaseX)))
--     local y = self.params.AmplitudeY * math.exp (math.tan((t / self.params.PeriodY + self.params.PhaseY)))
--     local z = self.params.AmplitudeZ * math.exp (math.tan((t / self.params.PeriodZ + self.params.PhaseZ)))

       return x, y, z
    end

    return orbit
end


Goto Eros. Being on the XY plane, for the moment try to incline a bit the cameraview to see the "depth" of the effect.
Last edited by Fenerit on Sun Oct 11, 2009 8:04 am, edited 1 time in total.
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

Re: Three Lissajous curves

Postby Cham » Sun Oct 11, 2009 7:58 am

This is working, but there's a two steps discontinuity jump at some stage which is really annoying. The pink ball is approaching from infinity, then reappears at another location before finally entering Eros. I know the motion is periodic, but there's an error in the trajectory.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
User avatar
Cham
 
Posts: 4208
Joined: Wed Jan 14, 2004 9:01 am
Location: Montreal

Re: Three Lissajous curves

Postby Fenerit » Sun Oct 11, 2009 8:04 am

Cham wrote:This is working, but there's a two steps discontinuity jump at some stage which is really annoying. The pink ball is approaching from infinity, then reappears at another location before finally entering Eros. I know the motion is periodic, but there's an error in the trajectory.


Yes, indeed. PhaseY should be = to PhaseX. I've corrected the code now.
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

Re: Three Lissajous curves

Postby Cham » Sun Oct 11, 2009 8:27 am

No, there's still a mistake (discontinuity jump in the motion). Just follow the ball and watch Eros approaching :

cel://PhaseLock/Sol:Eros:Scifi_docks%20 ... rc=0&ver=3
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
User avatar
Cham
 
Posts: 4208
Joined: Wed Jan 14, 2004 9:01 am
Location: Montreal

Re: Three Lissajous curves

Postby Fenerit » Sun Oct 11, 2009 9:04 am

Sorry, Martin there must be an incomprehension: I do not see jumps in the motion. Below there is a video made at 10x time.

http://marauder.webng.com/files/docks.avi 320x240 Xvid, 479kb

When Eros is toggled with ALT+rightarrow is seen as the motion is a spiral. Whether for "jump in the motion" you intend the jump once the ball is inside Eros to out, this is willingly introduced because the motion has been accomplished, the spaceship is in the dock. That motion must be consider as a "fragment" a "scene" of an action. The inverse motion (from the bay to hyperspace) is due to the furthers equations. Both motions are not close orbit as the former three.
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

Re: Three Lissajous curves

Postby Cham » Sun Oct 11, 2009 9:25 am

Fenerit,

the trouble I'm describing is seen when you follow the pink ball and watch Eros approaching (use the link I gave). Not the reverse. The video above can't show the problem.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
User avatar
Cham
 
Posts: 4208
Joined: Wed Jan 14, 2004 9:01 am
Location: Montreal

Re: Three Lissajous curves

Postby Fenerit » Sun Oct 11, 2009 9:49 am

Cham wrote:Fenerit,

the trouble I'm describing is seen when you follow the pink ball and watch Eros approaching (use the link I gave). Not the reverse. The video above can't show the problem.


Cham, I see that, and I see also that a galaxy appear in my visual. They are math issues; there are tangents in the module. But as long as the motion is assigned to an object instead of a camera, this latter is free to accomplish another motion... :wink:
Last edited by Fenerit on Sun Oct 11, 2009 9:51 am, edited 1 time in total.
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

Re: Three Lissajous curves

Postby Cham » Sun Oct 11, 2009 9:51 am

Yep, the maths aren't right. But once it is solved, it could let the user to travel into a spaceship through the whole universe ! :mrgreen:

The scriptedOrbit introduces the posibility to move a spaceship between several stars ! :o
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
User avatar
Cham
 
Posts: 4208
Joined: Wed Jan 14, 2004 9:01 am
Location: Montreal

Re: Three Lissajous curves

Postby Fenerit » Sun Oct 11, 2009 9:57 am

Well, indeed. But today my attitude was "sci-fi movies" like. I'm not a math genius, but also myself think that someone would develop more equations, so to say, to make a sort of "math pack" for these orbits.
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

Re: Three Lissajous curves

Postby Cham » Sun Oct 11, 2009 10:03 am

I'm playing with it right now. I'm changing the motion to all sorts of trajectories. I don't understand the syntax yet, though.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
User avatar
Cham
 
Posts: 4208
Joined: Wed Jan 14, 2004 9:01 am
Location: Montreal

Re: Three Lissajous curves

Postby Cham » Sun Oct 11, 2009 10:09 am

Ok, I now understand the maths. My test trajectory is working as expected. Expect some very cool new things from this technique ! :wink:

What are the units used in the SSC for all the parameters ? What are the units of PeriodX, Y and Z ?

And what about AmplitudeX, Y, Z ?

EDIT : I'll be able to define precessing orbits (relativistic perihelion advance for some pulsars, for example), volcano ejecta with CMOD sprites, solar protuberances, spiraling motion to a black hole, etc... and maybe even this :

http://antwrp.gsfc.nasa.gov/apod/ap060726.html

http://demonstrations.wolfram.com/MassT ... arSystems/
:mrgreen:
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
User avatar
Cham
 
Posts: 4208
Joined: Wed Jan 14, 2004 9:01 am
Location: Montreal

Re: Three Lissajous curves

Postby Cham » Sun Oct 11, 2009 11:08 am

There's a math library there, which will be very usefull to built complicated orbits :

http://lua-users.org/wiki/MathLibraryTutorial

Fenerit, please, edit the title of this thread so it reads something like "Scripted Orbit Tutorial"...
Last edited by Cham on Sun Oct 11, 2009 11:29 am, edited 2 times in total.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
User avatar
Cham
 
Posts: 4208
Joined: Wed Jan 14, 2004 9:01 am
Location: Montreal

Re: Three Lissajous curves

Postby Fenerit » Sun Oct 11, 2009 11:17 am

I can't wait! :D Amplitude and Phase are in km, instead, for what concern Period it I'm not sure but might be days. Anyhow, I noticed a thing: for speed movements in realtime is best to deal with the last decimals as were "frame rates" i.e 24, 25, 29.7, 30 fps.

Ahem, I don't know how to do for changing the title of the topic... :mrgreen:
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

Re: Three Lissajous curves

Postby Cham » Sun Oct 11, 2009 11:27 am

Fenerit wrote:I don't know how to do for changing the title of the topic...


Just edit your first message. The title is available there.
"Well! I've often seen a cat without a grin", thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!"
User avatar
Cham
 
Posts: 4208
Joined: Wed Jan 14, 2004 9:01 am
Location: Montreal

Re: ScriptedOrbit tutorial

Postby Fenerit » Sun Oct 11, 2009 11:33 am

The title of this topic has been changed from "Three Lissajous curves" to "ScriptedOrbit tutorial".
Never at rest.
Massimo

Mirror site
User avatar
Fenerit
 
Posts: 1793
Joined: Mon Mar 26, 2007 1:43 pm
Location: Tuscany, Thyrrenian sea

PreviousNext

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests