Here's one of my first Java apps. It uses Bresenham's line-drawing algorithm to draw pieces of lines as particles and simulate a nuclear chain reaction.

Below you should see a 100 by 100 window. Within are atoms (the raised circles - Java draws horrible circles). Soon a particle (small dot) should appear in the center, moving in a random direction. Whenever it hits an atom, the atom undergoes fission, becoming four particles. (The original particle is annihilated.)


Since modern browsers no longer support, Java, you'll either have to take my word for it, or download and run the applet source code.

The particles are interesting because they move using an implementation of Bresenham's line-drawing algorithm, rather than the standard velocity increments.

One benefit of using Bresenham's for particle movement is the automatic trails. The velocity of a "Bresenham particle" is expressed as a number of pixels. Each turn, the particle is stepped velocity times. This allows each pixel to be drawn, resulting in a trail.

Stemming from this is another advantage: better collision checking. With the standard velocity increments, a particle whose velocity is larger than the width of an atom could step right over the atom and never collide with it. A Bresenham particle actually calculates each intervening pixel, and so you can check at each step.

Finally, the direction of a Bresenham particle is not limited like a velocity particle with integer components. A velocity particle can only travel at integer ratios depending on its max speed. For instance, if the max speed of its X or Y velocity is 2, then there are only five directions it can go: x, y, x + y, x + 2y, and 2x + y. (Note that 2x + 2y is the same as x + y.) You could increase this to 18 directions by allowing it to go in negative directions. However, a Bresenham particle simply begins at a point and goes in the direction of some arbitrary point, limiting its angles depending only on the pixel width and height of the screen.