1
$\begingroup$

I implemented a simple simulation of a comet flying through space being deflected by the gravity of randomly generated planets for art purposes. My problem with that simulation is, that there are many "boring" simulations in which the comet instantly collides with a planet or is deflected to leave the viewport without an interesting trajectory.

Is there an efficient way to compute the initial values (gravitiy of the planets and initial velocity of the comet) for a simulation, in which the comet does not collide (early) with planets and possibly has an interesting trajectory (being deflected more often, slingshots, etc.)?

As I want to use it for art, there is no problem if the algorithm has constraints like only working for integer valued planet gravity or similar restrictions.

My current approach is using brute-force by simulating sets of parameters until I get an acceptable trajectory, which is rather slow.

Things I probably need (please comment to suggest others):

  • Points the comet should not cross (i.e planets)
  • Points with a specified velocity (e.g. near planets to deflect the trajectory from a collision course)
  • Maybe way points to guide the trajectory

The parameters should not be arbitrary (the comet does not have a motor), but boundary conditions for choosing planet gravity and the initial velocity of the comet. If it's useful, the comet's mass can be chosen as well. Currently I assume the comet to be massless, which probably approximates the reality quite good.

$\endgroup$
  • $\begingroup$ Have you considered using an analytic solution to get your parameters? $\endgroup$ – nicoguaro Feb 1 at 0:48
  • $\begingroup$ Yes, but I have no idea where to start and if it involves slow operations like solving large equation systems. I currently move the comet along the vector field calculated using the midpoint method, so I have in theory no grid. On the other hand, as I just need the visualization I could use the image pixels as grid if this allows for an efficient solution. $\endgroup$ – allo Feb 1 at 7:45
  • $\begingroup$ You can pick any classical mechanics book and check the two-bodies problem. $\endgroup$ – nicoguaro Feb 2 at 17:43
  • $\begingroup$ @nicoguaro I already thought so, but I hoped there may be some more advanced literature or some approximately solution to the problem. It should be more than two bodies, but it does not have to generalize to arbitrary n. Something between 5 to 10 or 15 bodies plus the comet (which could be assumed to have negligible mass) would be enough for a nice animation. $\endgroup$ – allo Feb 3 at 9:47
  • $\begingroup$ Can you explain what you mean by "collision"? Because in reality, the likelihood of anything in space colliding with anything else is vanishingly small. Or do you use oversized planets and comets so they look visually nicer? $\endgroup$ – Wolfgang Bangerth Feb 5 at 13:51
3
$\begingroup$

You're trying to solve the n-body problem, which has some known approximations that can be used to accelerate computation; however, it's still unclear how you can turn these into artistically interesting orbits.

Some thoughts:

Place the comet near the edge of one of your planet's hill spheres with a velocity just slightly above the planet's escape velocity and, possibly, near, but under, your solar system's escape velocity. This will give you a comet with a relatively stable orbit capable of traversing, and being perturbed by, most of the system.

Alternatively, you could set up an Hohmann transfer orbit between two planets in your system, but perturb the velocity so that your comet "misses" the intended orbit.

For more complex patterns, you could figure out how to use the General Mission Analysis Tool to multi-planet assists. You could also look into the Interplanetary Transport Network.

$\endgroup$
  • $\begingroup$ Thank you for the ideas and links, I will try what kinds of trajectories I can achieve. My current "interesting orbits" just consist of filtering for animations which have no collisions for x seconds, so that's not hard to beat. $\endgroup$ – allo Feb 3 at 10:27
  • 1
    $\begingroup$ This is a great answer -- the only thing I'd add is to make sure you're using a symplectic integrator. Naive methods often make the bodies collide or fly apart over long times even when the true orbit is closed or quasi-periodic, a problem that symplectic integrators usually avoid. $\endgroup$ – Daniel Shapero Feb 3 at 19:19
  • $\begingroup$ @Daniel: True. Though, from an artistic perspective such as OP mentions, using a low precision integrator might actually be preferable. $\endgroup$ – Richard Feb 4 at 1:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.