Physics! (the Kerbal Space Program way)

Discussion in 'Planetary Annihilation General Discussion' started by stromgol23, July 31, 2013.

  1. stromgol23

    stromgol23 New Member

    Messages:
    10
    Likes Received:
    1
    First of all, thanks for the awesome demo on the livestream yesterday. I've seen people mentioning kerbal space program in chat and I feel you guys should really check that game out (if you haven't already :D ). KSP chose some very interesting solutions to keep the physics relatively simple and the gameplay fun. I've wrote a quick summary of the two bigger ones imo.

    KSP has two modes of simulation: a time step mode (just like Ryan showed in the demo) and an "on-rail" mode. In time step mode you save position and velocity on every body in the system and then recompute them based on all forces applied to the bodies for the time step. The smaller the step the more precise the simulation.

    In the "on-rail" mode they save the whole orbit for every body. Basically you save six values (orbital parameters) that lets you draw the whole ellipse/parabola/hyperbole. To find the position of the body you just need the current time. You can't apply any forces on the body, that would change the orbit and you'd have to recompute the parameters. It also only works in a 2 body system. They use this sim when they enter time acceleration which is very needed in a spaceship sim ;). Not so much in PA.

    They also implement SOI (sphere of influence) transfers. Basically it's just a way to change reference bodies. In a 2 body solution, one body is the spacecraft, the other is the object it's orbiting. The SOI is the region where the body's gravity is prominent. If you're in orbit around earth you're in earth's SOI. You approach the moon and enter it's SOI; this means that now the moon's gravity is more important than the earths. At that point you can change the reference body from earth to the moon. It makes "rendez-vous" solution finding more complex but the sim looks a lot better. This is something PA could definitely use imo.

    Definitely recommend you guys check these out. The scale of PA and KSP are very different but it's essentially the same calculations underneath ^^
  2. asgo

    asgo Member

    Messages:
    457
    Likes Received:
    21
    just to get it in here:

    [​IMG]
    xkcd

    please continue. ;)
  3. Teod

    Teod Well-Known Member

    Messages:
    483
    Likes Received:
    268
    I'm afraid you're wrong. Planets and moons in KSP are always on a rails (those rails are physically correct, but they are calculated outside of the game), there is no N-body gravitation and real time physics only apply to the craft that you're piloting and other nearby (closer than 4km) crafts.
    While their solutions are good, it seems that PA is already way ahead of KSP when it comes to orbital mechanics.
  4. kryovow

    kryovow Well-Known Member

    Messages:
    1,112
    Likes Received:
    240
    How would you say that? The approach is totally different, also the things, that have to be simulated and processed cannot be compared... I cant see, where PA's physics simulation is ahead of KSP, when PA simply can simulate orbits by now, with instantaneous changes of orbit parameters.
  5. nanolathe

    nanolathe Post Master General

    Messages:
    3,839
    Likes Received:
    1,887
    KSP doesn't even attempt n-body simulations; it's strictly limited to 2-body simulations and there are absolutely no plans for it to support n-body physics.

    Uber's calculations can simulate n-body simulations... there's just a toggle to turn them off.
    ;)
  6. Teod

    Teod Well-Known Member

    Messages:
    483
    Likes Received:
    268
    If we talk about physics in general, they really can't be compared properly.
    If we talk just about orbital mechanics, PA already has multi-body gravitation, which KSP doesn't.
    And continuous burns are not significantly different from instantaneous trajectory changes because of how time in videogames works.
  7. stromgol23

    stromgol23 New Member

    Messages:
    10
    Likes Received:
    1
    N-body is somewhat trivial to do in a time step system so you'll be able to run the sim in it. However I'd be really surprised if gameplay is supported. Ryan wrote the intercept code for 2 body systems because it's a somewhat simple formula. There's no formula for that in a n-body system.

    More importantly there's really not that much gain in using n-body in a game. KSP will indeed never support n-body simply because it makes no sense to do so. Most of their cool features wouldn't work.

    PA is a rts. All you want is select asteroid, click target planet, watch fireworks :)
    (well ok, more than just that ^^)
  8. supremevoid

    supremevoid Member

    Messages:
    340
    Likes Received:
    0
    Kerbal Space Program has a very different way to simulate it, to be simple here. I think PA will do a much better Job on 2-body simulations.
    Universe Sandbox is a great example on how great Orbiatal Object Simulation can work.

    This sentence is awesome :cool:
  9. kryovow

    kryovow Well-Known Member

    Messages:
    1,112
    Likes Received:
    240
    though you absolutely have no advantage of simulating n-body solar systems. n-body gravity problems mean a lot of orbit disturbance. eventually the solar system could break and planets will chaotically fly around. and the CPU you would need for something like that....
  10. menchfrest

    menchfrest Active Member

    Messages:
    476
    Likes Received:
    55
    The advantage of n-body simulation is you get more of the cool results that are possible in orbital mechanics (See Lagrange points (requires 3+ body problems), Interplanetary transport network (needs at least Lagrange, maybe full n-body)).

    Also, we saw the n-body sim running, if we're talking about 10's maybe even low 100's, it shouldn't get too out of hand. And let's be honest, how long are those 100+ asteroids gonna last? :p
  11. plannihilator

    plannihilator Member

    Messages:
    55
    Likes Received:
    2
    The main problem they mentioned for N-body simulation is the chaotic nature of movement when accelerations are high and the movement is calculated over a fixed time-step : small errors accumulate and quickly kick the object out of its orbit even though it physically should stay.

    One work-around could be to switch movement calculation for objects meeting "chaotic divergence criteria" by dramatically decreasing the time step just for these objects or simply switching to a completely different mode of trajectory calculation devoid of divergence problem (but probably more calculation intensive but it is fine if it concerns only a few asteroids).

Share This Page