Computing planet orbit's

About the actual programming of the game.

Re: Computing planet orbit's

Postby jherico » Sat Aug 24, 2013 6:30 am

There's no issue of percent error here. If you're only ever under one body's influence at a time there's a ton of stuff you can't actually do. Slingshot orbits and Lagrange points come immediately to mind.

I don't think it's necessary to actually model gravity all the way from the top to the bottom. Short of building a moon or planet sized craft with the engines to match, every user controllable craft in the game is almost certainly going to have negligible impact on the orbits of the major bodies. So anything that's a celestial body simply gets a precomputed orbit (not necessarily a perfectly elliptical orbit, you could still have them perturb one another, as in Jupiter altering the orbit of Earth slightly, but either pre-computed or with much larger time intervals for iterative calculations) and anything that's a player craft simply deals with gravity as a single vector, which is the sum of all the influencing celestial bodies above a certain cutoff, and which is recomputed on a small enough timescale that it doesn't matter that it's not perfectly continuous.

This should give you the full functionality of Newtonian gravity, though of course it would start to fall apart if you start getting close enough to a rotating black hole or binary neutron star. Hopefully any such situation would be sufficiently deadly to the player as to make accurate modeling of dragging effects academic.
jherico
 
Posts: 13
Joined: Wed Aug 21, 2013 2:35 am

Re: Computing planet orbit's

Postby Zardoz » Sat Aug 24, 2013 11:11 am

I think that we get a enought good gravity simulation if we only ever under TWO nearest bigger bodys influence... aka a Planet and a Moon, or a Planet and a Star, etc... Need less computing power and give you langrange points and Slingshots orbits.

PD: The way that KSP simualte gravity, keeps working Slinshots orbits.
Yep, I have a blog : http://zardoz.es
Emulator DCPU-16 VM
User avatar
Zardoz
 
Posts: 359
Joined: Mon Aug 12, 2013 8:54 pm
Location: Spain

Re: Computing planet orbit's

Postby mrout » Sat Aug 24, 2013 1:56 pm

Zardoz wrote:I think that we get a enought good gravity simulation if we only ever under TWO nearest bigger bodys influence... aka a Planet and a Moon, or a Planet and a Star, etc... Need less computing power and give you langrange points and Slingshots orbits.

PD: The way that KSP simualte gravity, keeps working Slinshots orbits.


That's just silly. All non-planets are affected by all planets in the system. All celestial bodies have pre-computed fixed elliptical orbits.
mrout
 
Posts: 731
Joined: Mon Aug 12, 2013 10:49 pm

Re: Computing planet orbit's

Postby croxis » Mon Aug 26, 2013 1:24 am

Right. Patched conics do model slingshots.

Raph Koster has written a bit on this topic. The short version is that players don't give shit how clever a programmer or their code is.

Here is a slightly different case: Someone made a spacegame that he wanted as realistic as possible. Instead of classical newtonian he went with always using einsteinian gravity modeling and red/blue shifting and other light distortions are calculated each frame in the shader. He hit the compile button and uploaded his game. "I am brilliant!" he would think as he stroke his neckbeard as he went to sleep. Now the game uses ftl to get around places fast and it would take an entire of year with the normal engines at 100% to for a player to even notice any differences; the game wasn't designed around relativistic effects. He woke up the next day and checked out his game's forums. "Sweet! Newtonian physics!" someone posted. "NO! It Uses Relativity you fool!" typed the programmer. However, due to how players heuristically understand a game, it became an epademic of "NO YOU FOOOLS!" posts as the programmer tugged on his neckbeard in frusturation and resorted to eating his toe jam as a source of nutrition in keeping up with the forum posts.

(On the other side - the old Microsoft space shooter Allegiance didn't use classical physics -- but the wing-commander style airplane in space flight style. What they added was that the velocity vector would shift much slower so there would be sliding/drifting as part of regular combat. Many players thought there was classical physics being modeled just because the ships slid on turns)

Now in this specific example newtonian physics is an excellent almost 1:1 approximation -- all the features with a much better computational speed.

So I ask again. As a player what do I get with an n-body simulation, or what is different, over patched conics. On one hand, I get L points. On the other hand the physics engine wont be able to simulate as many ships.

Or, to ask another way from a technical standpoint with my very poor understanding of big O notation -- Patched conics is O(x): The physics engine only has to calculate the g force of one planet per ship. N-Body, if one goes for a full simulation of every body in the system, is O(N*x) where N is the number of bodies in a system. Still linear but the slope can be significant -- Saturn has 70 moons. For 128 ships in saturn is 128 gravitational calculations using patched conics. Nbody is 10240 (also adding the effects of the sun and other planets, but not their moons). So what number of ships a physics engine running at 120 fps can model (including all the other elements the physics engine needs to deal with) with patched conics vs nbody in the maxmimum expected size of a system?
croxis
 
Posts: 282
Joined: Tue Aug 13, 2013 1:37 am

Re: Computing planet orbit's

Postby mrout » Mon Aug 26, 2013 6:49 am

croxis: I advise you to read again. I'm not suggesting we use an n-body simulation, just that instead of just 1 body affecting a craft at once, a few affect it - namely the star in the system, all NEARBY planets and any NEARBY moons.
mrout
 
Posts: 731
Joined: Mon Aug 12, 2013 10:49 pm

Re: Computing planet orbit's

Postby cdrakep » Wed Aug 28, 2013 2:03 am

20k wrote:
rsgm123 wrote:Is n-body out of the question? it may make for interesting gameplay, even if it is just for asteroids(if there are any).


From a server standpoint, n-body is a terrible idea. For a largish number of asteroids it requires an unreasonable amount of CPU power. On a realism standpoint, I believe asteroids are generally too far apart to exert any meaningful kind of gravitational pull on each other. A fixed elliptical orbit is probably realistic enough, with potentially the option of player's being able to move them coming at a later date


N-body isn't out of the realm of possibility if there are strong level of detail constraints. LOD could also be variable depending on the resources and what the server admin is looking to accomplish. There should be reason that asteroids on close elliptical paths could not influence each other when they're distance crosses a threshold.

As to Lagrange points, they can be pre-computed using procedural methods, and given point sources of gravity to simulate them...
cdrakep
 
Posts: 2
Joined: Tue Aug 27, 2013 12:17 am

Re: Computing planet orbit's

Postby mrout » Wed Aug 28, 2013 9:58 am

That's right, yeah. Once a body is below (say) 1% total gravitation effect on a body, it's just completely ignored. We can update which bodies affect something once every second or 5 seconds or something - relatively infrequently, anyway.
mrout
 
Posts: 731
Joined: Mon Aug 12, 2013 10:49 pm

Re: Computing planet orbit's

Postby adam » Wed Aug 28, 2013 2:55 pm

So just compute a SOI for each body and use that to determine if a body is affecting something.

For computing orbit just do it once because realistically the player wouldn't see the orbit being affected by other bodies unless they sat there fora very long time to watch its orbit.
adam
 
Posts: 113
Joined: Tue Aug 20, 2013 11:58 am

Re: Computing planet orbit's

Postby cdrakep » Thu Aug 29, 2013 4:48 am

You can realistically pre-compute roughly when a SOI will cross a threshold and time when it's necessary to check whether it needs to be considered in the local LOD threshold
cdrakep
 
Posts: 2
Joined: Tue Aug 27, 2013 12:17 am

Re: Computing planet orbit's

Postby Alderin » Tue Sep 10, 2013 8:44 pm

Just a minor thought: Orbits are slow, space is vast, and huge volumes of space will have negligibly similar combined gravity vectors.

If a star system virtual 'grid' is established, with very large volume cubes, pre-calculation stored in the cubes could happen in periods as far as hours apart. It stands to reason that they could be pre-calculated daily for the upcoming game day. Then the planets and other heavy bodies could have a pre-calculated 'sphere of influence' when a planet's influence is >1% (say) for closer calculations to remove the inaccuracies in blocks where the vectors are not negligibly similar.
Alderin
 
Posts: 67
Joined: Mon Aug 19, 2013 7:02 pm
Location: San Jose, CA

PreviousNext

Return to Code

Who is online

Users browsing this forum: No registered users and 1 guest

cron