Sign in to follow this  

Runge-Kutta in a large solar system

This topic is 1117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi!

 

I have a quick question about relative coordinates in a simulation of the solar system. Let's say I am simulating a spacecraft using an RK4 propagator in an environment containing the Sun, the Earth and Mars (with the Sun at the centre). The two planets are on simple circular orbits around the Sun to make calculating their positions easy.
 
My problem is this: If the spacecraft is initially orbiting Earth, it seems like specifying its position/velocity relative to the Sun is not a very elegant idea due to the large numbers involved and the fact that the Earth is moving relative to the Sun at about 30km/s. Do you think it's a good idea to implement a system which, for every timestep, determines which body is imparting the largest acceleration on the spacecraft and do all the propagations in coordinates relative to that body?
 
It also seems like if I am trying to simulate a spacecraft initially in orbit around Earth (which is 1.496e11 metres from the Sun), I will run into floating point inaccuracies in my propagation calculations. Should I just use doubles, or is there a more elegant way of doing this?
 
Thanks a lot :)

Share this post


Link to post
Share on other sites
What Ravyne said.

An easy trick for keeping your precision clean is to simulate the solar system at a "virtual" scale of 1.0 = 1 AU, a planetary orbit at 1.0 = 0.1 AU, etc. When you need to convert between coordinate systems for some reason, you can simply scale them to get them into the correct "scale space" (of course a translational/rotational transform also has to be done).

Share this post


Link to post
Share on other sites


If I'm going to play a space game it isn't going to be "Realistic Simulator of the Voyager Probe, Year 37", but something like EVE Online with active play and completely fake but very engaging physics rules.

 

OP never said it was a space game, maybe George does want to make an accurate solar system simulation (Orbiter-like, perhaps?) with possible time acceleration and faster than light camera movement (such as in Space Engine). In any case, fun game mechanics can also be designed around such simulations or at least a subset thereof, a space game doesn't *have* to have fake submarine physics and be action-based. But yes, modifying gameplay to have less need for such high accuracy is one available option.

Share this post


Link to post
Share on other sites
The first thing that came to my mind when I read the OP's post in the context of game development was Alien Legacy. It did simulate a solar system with all bodies orbiting correctly inside their respective system ('correct' in this case means in regard to it being 1994 and me being a lot younger). I'm not sure about the exact time scale but if you cranked up the speed weeks or months passed within seconds, so doing that while watching the system map allowed you to actually observe the path of the planets around the sun.
That said, if I would implement something like that I would probably neglect a physics simulation of the solar and instead go with an idealized analytical description of all the bodies. Unless of course I planned to allow using bigger bodies (like moons upwards) as weapons later on...

Darn. Now I'm not getting Alien Legacy out of my head. And it's not even available on GoG. I hope I have a copy from way back then stashed away somewhere...

Share this post


Link to post
Share on other sites

Thanks for the help. I have solved it by using a coordinate system for each planet, and if the spacecraft is outside any of the planet's spheres of influence, I use the Sun. Just to clear it up, this isn't really for a game, it's for a project in which I need to simulate an interplanetary flight and then display the trajectory on screen. I figured that this is a common issue in space-related games though. Having the different coordinate systems makes it easier to display the results too.

Share this post


Link to post
Share on other sites

This topic is 1117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this