This is a 2D simulation for motion of colored balls in a round container with no collisions among them but collision with wall is allowed. There are options to enable a fake (anti)gravity and dump/
enhance velocity during the collision with wall but these are intended to produce only graphical
effects for animation because this is a toy and it doesn't integrate real motion equations following
real physical laws of motion. Initial conditions follow a very simple distribution of points f(x) and velocity field f(v) so particles will try to fill homogeneously the drawing area and velocity directions will have no preferencial direction, I hope.

This is written in standard C and uses Motif/Lesstif widgets. Notice this was only tested under 24bits color depth.


The basic code is used by several examples with slightly different options. The early code used to simulate a squared container because that was very simple. Later versions changed to a round container and bounce at boundary follows a simple rule: angle with normal is maintained during bounce at boundary,i.e., velocity vector and normal vector of surface has a angle and the particle will bounce at surface following rule similar to that already known from optics.
The image below is a snapshot of default number of particles and the example is the last working code:


Animatedballs is intended to be a -toy- which produces a simulation for non-collisional particle motion. Motion can be submitted to external forces as a fake gravity or a fluffy wall.

There is another project using particles which is hosted in sourceforge:

License is GPL.

Thanks to for hosting this project.
This page is expected to work for any browser.
SourceForge Logo