Wrapping N-Body Simulation

Continuing with my previous efforts, I updated my N-Body simulation code to not require the edges of the simulation to be boundaries.  Instead, the edges now wrap.

That might seem like a pretty simple change, but the code involved gets a bit complex…

For example, say you’re calculating the force between particle A and some other particle B and particle B’s force is wrapped around the screen, you need to basically translate B to the other side of A and do your calculation…

If you’re in a corner… say the upper right, you’d have to do this with all particles above and all particles to the right of you, so you’d need to do two sets of transformations.

The process is slow enough with 100,000 points that I need to think about moving from Java, which is what the simulation is currently written in, to something speedier, like C.