-1

I'm programming a gravity system, based on this answer, and I've also tried this approach.

Everything is working fine, but I want the objects to pass through each other without any collision and to keep an harmonic motion,. To see what I mean, try placing two planets on this simulation with 'Merge off'.

However, on my implementation, there's a point in which the bodies are very close and they make a huge force on each other, getting them into unexpected places.

I guess this can be solved by using adaptative time steps and/or trying different integration approaches. However, I'm sure there has to be a simple, hacky way to get the harmonic behaviour descrived above.

Any help?

1 Answers1

0

Bodies being very close and imparting huge forces on each other ultimately means huge speeds. But this implies very small time of passing through (if you take this approach; in general this is an ill-defined situation). Thus at some distance, when the particles are sure to pass through each other (this is in the case of zero angular momentum), you can just move them as if they have passed already. You may just want to adjust the time when they appear at the new position by estimating how long it would actually take (two-body problem is exactly solvable).

Ruslan
  • 30,001
  • 8
  • 70
  • 154