A demo of what I've been working, thanks to all who helped

Pagnatious

New member
Joined
Mar 3, 2010
Messages
24
Reaction score
0
Points
0
Hi,

This past while I've been working on a project that involves a 2D simulation of planets and ships/stations moving in orbits. I have built up my knowledge of orbital mechanics and how to calculate and implement variables needed for this mainly from reading wiki and for the forums here, either passively or from the help of people, but my understanding still has gaps.

What follows is a brief description of its process, then a link to an example with some controls.


Here is an example of it http://www.patrickhogan.org/Solar.htm

It has mercury, earth, the moon and mars as well as a ship in green.

Controls (you may have to click in the window to give it focus):
1 - stops time
2 - sets time rate relative to ships orbital period
3 - sets time rate at 100min/sec (starting speed)
4 - sets time rate at 1000min/sec
5 - reduces time rate by 50 (floored at 0, no back in time :)
6 - increases time rate by 50

- and + zoom in and out
e focuses the camera on Earth
c on the sun,
s on the ship
space on the midpoint between the ship and what it's orbiting.

Arrow keys will change the ships velocity by increasing it in the relative cardinal directions. Crude but only for demo purposes.

Clicking on a different body will change that to be the ships target and as such intercepts will be worked out for that. Need to make it so you can tell more precisely if your path is going to meet where the planet is.

The rings around the planets/moon are their sphere of influence and the ship uses a patched conic approximation approximation for its motion. It's elements are determined based on whose sphere it's in. As it passes down to a new sphere like the moon its position and velocity become relative to it.

I think I got all the bugs out, but feel free to let me know of any if you try it.

Any thoughts, opinions, criticisms or comments are welcomed.
 
Last edited:

Pagnatious

New member
Joined
Mar 3, 2010
Messages
24
Reaction score
0
Points
0
Now it show's where the moon will be when the ship crosses its orbit.
 

garyw

O-F Administrator
Administrator
Moderator
Addon Developer
Tutorial Publisher
Joined
May 14, 2008
Messages
10,485
Reaction score
209
Points
138
Location
Kent
Website
blog.gdwnet.com
Sounds interesting but the website is timing out for me.
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Orbiter Contributor
Addon Developer
Webmaster
GFX Staff
Beta Tester
Joined
Aug 9, 2009
Messages
6,922
Reaction score
789
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
Not for me, I had a little play. It's pretty well-made, I like it!
 

garyw

O-F Administrator
Administrator
Moderator
Addon Developer
Tutorial Publisher
Joined
May 14, 2008
Messages
10,485
Reaction score
209
Points
138
Location
Kent
Website
blog.gdwnet.com
Still not working here so it's almost certainly down to the work internet connection routing being broken again. I'll have a play this evening - cheers Xyon.
 

orb

O-F Administrator,
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
Works fine for me too. One note about keys: I always mistake 'c' with 's'. I think 's' suits more to the Sun, and 'c' to the craft/vessel (the ship).

I needed to switch back to this thread to check what's wrong with controls. Maybe a list of keys just below the flash object would solve it for me.
 

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,427
Reaction score
491
Points
173
Location
Among bits and Bytes...
No perturbations? Looks like when you're outside of the sphere of influence of the small body, the main one takes over completely, with unexpected results.
 

Moach

Crazy dude with a rocket
Addon Developer
Joined
Aug 6, 2008
Messages
1,581
Reaction score
62
Points
63
Location
Vancouver, BC
hey cool!

nice to have some colleague Flash-devs around! :salute:


are you using any type of integrator for this? (things can get very unstable otherwise)...
any chance we could share some code?

i see how this could turn into a really neat training device for newbie orbinauts which, like myself, often fumble about interplanetary transfers...


i also have a project pending at work that will require some orbital calculations (yep, a kind-of "flash orbiter")... and i was thinking i could even use that Alchemy thing to compile the KOST library used in the open-orbitMFD....

anyways, i digress... back to you! - very cool prooject!:thumbup:
 
Last edited:

Columbia42

Member
Joined
Dec 4, 2009
Messages
884
Reaction score
0
Points
16
Location
C:\ProgramFiles\Orbiter
Looks great!

---------- Post added at 02:51 PM ---------- Previous post was at 02:48 PM ----------

BTW, the site worked fine for me. Just a suggestion, in a later version (if those are planned) it might be interesting to also have a side view of the system (making it 3D) in another window. More planets would be neat too.
 

Pagnatious

New member
Joined
Mar 3, 2010
Messages
24
Reaction score
0
Points
0
Thanks for all the comments.

One note about keys: I always mistake 'c' with 's'. I think 's' suits more to the Sun, and 'c' to the craft/vessel (the ship).

It was C for center in my head. Only preliminary at the moment, just while I was working the bugs out. The idea is to be like truck driving/ cargo ships in space. Getting contracts at stations to bring X to Y with a time limit for a reward. Such is the idea anyway. Putting the keys below one the page is a good idea either way. Thanks.

have a side view of the system (making it 3D) in another window. More planets would be neat too.

I was keeping things 2D for now to keep things simpler, not have to worry about plane changes for transfers or the like. Am intending on having as far as saturn at least and a choice selection of asteroids and moon's. Just need decide which ones and to copy and paste the needed data from JPL Horizons. Position vector in km at 1/1/2000, mass in kg, GM, radius in m and name.

are you using any type of integrator for this? (things can get very unstable otherwise)...

I don't think I am, which probably mean's I'm not, and if things are liable to get unstable I probably should. Can you elaborate?
I would be willing to share some code yes. The crux of it comes from finding true anomaly at time, and methods to convert state vectors to elements and back. I made them by lots of Wikipedia and poking around in KOST

It certainly helped me understand and visualise the meaning and implications of the different factors involved.

No perturbations? Looks like when you're outside of the sphere of influence of the small body, the main one takes over completely, with unexpected results.

Do you mean the passage of the moon effecting the orbit of the ship around the earth? At the moment it generates elements for the ship based on only the body whose sphere it's in and then changes that as you pass in or out changing its vectors to be relative to that body.
I had originally planned on basing the ships movements on a gravity simulation, getting it's combined acceleration from the bodies and moving it based on that, but I reckoned that would make life hard for changing time speeds. I'll try having the other bodies effect it and see how that effects things.


Also, as you see, the bodies are drawn as black dots. Once zoomed in enough for them to be at least 1 pixel across they are drawn to scale.
 
Last edited:

River Crab

SpaceX Cheer Captain
Addon Developer
Donator
Joined
May 4, 2010
Messages
945
Reaction score
3
Points
18
Location
Washington, D.C. area
Very cool, beautiful in its simplicity!
I imagine it might be a great help in understanding how orbital mechanics work, for would-be Orbinauts. Of course, this would take more work to accomplish and make understandable, but that's what comes to my mind, and I don't think we have such thing already.
May the :probe: be with you!
 

Pagnatious

New member
Joined
Mar 3, 2010
Messages
24
Reaction score
0
Points
0
Thanks, just added Venus, Jupiter and Ceres in. Will probably add Saturn in a moment, then some moon's I reckon...

Really easy to add extra bodies
I've been using xml, though really I've been using it wrongly and should correct the syntax to use attributes and not subnodes...

Position and Velocity in km/s, Mass in kg, Radius in km, GM in km^3s^-2

Code:
	<Body>
		<Name>Earth</Name>
		<Epoch></Epoch>
		<GM>398600.44</GM>
		<Mass>5.9736E+24</Mass>
		<Radius>6371.010</Radius>
		<px>-2.648441906380038E+07</px>
		<py>1.446999859518467E+08</py>
		<pz>-6.122262704297900E+02</pz>
		<vx>-2.979479134658754E+01</vx>
		<vy>-5.466324852489777E+00</vy>
		<vz>1.805638504031037E-04</vz>
		<Body>
			<Name>Moon</Name>
			<Epoch></Epoch>
			<GM>4902.798</GM>
			<Mass>734.9E+20</Mass>
			<Radius>1737.530</Radius>
			<px>-2.915692716223896E+05</px>
			<py>-2.749713951461635E+05</py>
			<pz>3.627121570035505E+04</pz>
			<vx>6.435274736913783E-01</vx>
			<vy>-7.309781341969069E-01</vy>
			<vz>-1.150616176758562E-02</vz>
		</Body>
	</Body>

Been toying around with perturbations. Wondering what the best way to deal with it is, if there's a way to gradually change the path of the ship from being an orbit of the earth to an orbit around the moon.

Also, the high eccentricity bug seem's to still be there. Eccentric anomaly isn't calculated correctly for really high 0.9999< e <1 orbits. Even with 10000 iterations it sometimes comes out wrongly and the ship jumps position. I thought I'd fixed it by using the previous eccentric anomaly as the guess for the next time step, but no joy.
 
Last edited:

jedimaster1214

CDR-LMP-CMP
Joined
Jul 23, 2009
Messages
386
Reaction score
0
Points
16
Very nice!:thumbup:
Got into the moon's orbit really quick, now to figure out a voyager-style slingshot...:hmm:
 

Pagnatious

New member
Joined
Mar 3, 2010
Messages
24
Reaction score
0
Points
0
Looks great! As River Crab said, it's beautiful in its simplicity. Just wondering, is there a key to reset time to normal?

Thanks. There is now, 3 is the same as starting speed. Also added a few other speed changes and clicking to change target.
 

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,427
Reaction score
491
Points
173
Location
Among bits and Bytes...
Sometimes the ship just disappears. I just ejected from the Moon back to Earth. My orbit was hyperbolic, but before I even got to the perigee, my ship disappeared.

Sometimes it also skips a bit, mainly when velocities get high.

Also, how do I zoom out? Pressing c to go to sun-centered view just gives me a giant black dot across most of my screen. + and - don't seem to work.
 
Last edited:

Shinrar

New member
Joined
Jun 24, 2010
Messages
62
Reaction score
0
Points
0
Still not working here so it's almost certainly down to the work internet connection routing being broken again. I'll have a play this evening - cheers Xyon.

Ditto here. The link (in multiple browsers) fails to connect. I also tried the root site (http://helios.patrickhogan.org/) and that failed as well... Later today when I'm on a different network, I'll try again and see if thats the issue...

As a side note, I can ping the web address, so I know the DNS is working.

::shrug::
 

Pagnatious

New member
Joined
Mar 3, 2010
Messages
24
Reaction score
0
Points
0
I knew it skipped for high eccentricity elliptic orbits but not hyperbolic ones. I'll look into that. Does it actually disappear or just jump off screen? If it really glitches it might appear in the top left corner. Not sure why + and - wouldn't be working.

I'll try it on another server as well.
 

jedimaster1214

CDR-LMP-CMP
Joined
Jul 23, 2009
Messages
386
Reaction score
0
Points
16
Also, how do I zoom out? Pressing c to go to sun-centered view just gives me a giant black dot across most of my screen. + and - don't seem to work.


You have to use the + and - on the main part of the keyboard, not the Numpad...

That's what works for me...
 
Top