Home > Software engineering >  Planet position by time
Planet position by time

Time:06-20

I wanna implement a gravity system in shadertoy without using any storage/buffer. So i can't save any variable and my animations must be a function of time. Is it possible to make a function of time to calculate current position of the planet?! I'm confused at all, because next position depends on the current velocity and current velocity depends on the former acceleration and that depends on former position. Is it theoretically implementable as a function of time? Note that planets aren't located in circular and constant orbits. but they have first position and velocity.

CodePudding user response:

Even in the case of the two-body problem (Newtonian gravitation), you can't express the position of a planet as a simple analytical function of time and you need to resort to numerical integration.

So I don't see how in a more general case you could compute positions without using variables.

CodePudding user response:

time function is possible only if you use Kepler's equation instead of gravity simulation...

That is doable only if you have stable orbits and note its just approximation of the true trajectory.

See related:

You can do a hybrid approach where you use Kepler for stable orbits and once interaction is triggered (by close proximity of objects) you convert back to Gravity model , compute interaction result and convert back to Kepler (I assume that is how KSP is doing it).

so You should have a list of Keplerian trajectories with their time duration for each body and then just use the correct one for queried time ...

So when put all together I would:

  1. compute initial Kepler trajectories

    so compute points on single orbit and obtain orbital parameters from it

  2. compute close encounters

    so times when bodies are near each other (similar to intersection of ellipses) see:

  3. for each encounter recompute gravity model and create new Kepler trajectory

    Add it to list of body trajectories that will be valid after time if encounter ...

  4. If any encounter up to some time limit found goto#2

Now if you want to know where body is in time t just look to its list of Keplerian trajektories, use the one that has its valid time >= t while valid time is smallest and just compute your position, speed or whatever you need...

  • Related