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