Runge-Kutta in a large solar system

Started by
6 comments, last by george7378 9 years, 5 months ago

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 :)
Advertisement

When you're dealing with that much sparsely-populated space, and equations of that magnitude, its quite common to not deal with everything in a single space -- the numbers just start to break down unless you're willing to eat the cost of using math library with sufficiently-large precision, you won't get it out of floats or doubles. I'd probably have each planet be its own coordinate system, which itself orbits the sun's coordinate system. Likewise for moons as they relate to their planets. Then, based on the masses of the bodies involved, you'll be able to determine a radius within which that body is the one exerting the most force, and you can either switch over to just using that one, or you can also calculate for other bodies and interpolate the forces -- depends on how accurate you want to be.

throw table_exception("(? ???)? ? ???");

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).

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Thanks for the reply :) Yes, I was thinking of evaluating which body is causing the largest acceleration magnitude and doing the propagations with respect to that one.

Be aware that very few space-style games use actual real dimensions and scales, nor do they calculate actual physics for planetary bodies.

Think about what it means to have gravity and orbits around planetary bodies:

You've got the moon that orbits Earth in about a month. For a player looking at the Earth and their environment when rotating at that speed it will be indistinguishable from being stationary. You've got satellites that are geostationary, that is, relative to the Earth they don't move at all. You've also got smaller bodies in lower orbits, the ISS orbits the Earth every 90 minutes, there are satellites that orbit even faster than that.

In other words, if you are planning on orbiting the planet you can make it any animation you want. Zero relative is perfectly acceptable. High speed rotations are perfectly acceptable.

Since natural ranges include everything from stationary to high-speed motion, do whatever is easiest. Normally that means a static scene.

Then when it comes to things like interplanetary travel, you either better allow for some kind of jump system, or a loading screen style transition between areas. Figure that even if you allowed traveling at the speed of light it can still take 20 minutes to travel from Earth to Mars. If you want to have physics based travel you better have some really good music or something interesting for the player to do, because waiting around watching a space ship travel through the void is even more boring than level grinding.

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.


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.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

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...

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.

This topic is closed to new replies.

Advertisement