# Three-body dynamics simulation in Java

Have you seen Contact or Armageddon movies? If you did you should have a very good idea of how outer space looks like. Black. Cold. Unpopulated. Now imagine distant outer space some millions of light years away from our planet... Feel like God for a while: place three extremely hot and heavy stars there and then push them in different directions and with different velocities. What happens then? Who knows the answer? Will these stars clash or fly away from each other? Well, you probably won't believe but physicists nowadays while zillions of light years away from our place can tell you exactly what will happen. No guessing, no spiritualism, no science fiction. Just a famous Newtonian law of gravitation, initial data and a powerful Intel- or AMD- or Cyrix or you say it -based computer. The applet below allows you to predict the behaviour of our stars right on your screen and discover for yourself how it all works. See it and enjoy it alone or with your friends. Isn't it amazing that man can understand nature that deep while being so weak and vulnerable compared with planets, stars and galaxies?

Now sit more comfortable and prepare to observe. [go]

Left-click on the applet window to switch to full screen mode. Right-click to restart the simulation. Do it if particles disappear from the applet screen. Click here to look at the same slightly changed applet which you may find even more beautiful. You can see a similar applet with an attractive-repulsive interaction potential here.

This applet simulates 2D three-particle classical dynamics. The interaction potential is given by the formula U(r) = -1/r. It's an ordinary Newtonian gravitational potential. At the initial moment all particles have random velocities whereas the velocity of their centre of mass is equal to zero. Runge-Kutta method is being used to calculate particle trajectories with a time step depending on distances between particles and their velocities. This applet visualizes particle chaotic movement with disappearing trails and allows to track their trajectories without cluttering the view. On slow computers the applet automatically reduces the trail length so that you experience no noticeable slowing down of the particle dynamics.