Enough with single Particles, try an entire Particle System

Friday, November 14th, 2008

More experiments with Processing and Particles. This one uses the wonderful Traer Physics library.

Rather than writing a custom Particle class and applying forces to them individually (as in my previous particle post), all I need to do is create a ParticleSystem instance, add forces as desired (none in this case), and Traer does the rest.

In this example, I continuously add particles in the center with random velocities, and continuously remove them when they’ve grown old. The particle.age() property also controls the size and transparency of each particle, which is simply an ellipse with a teal-ish fill. The moon is a PNG placed in the center. For a final touch, I use the built-in camera() function to zoom in an out, controlled by a Sine wave.

1,000 Particles in Action. Part 2.

Sunday, November 9th, 2008

Actually, this one uses 10,000 particles, and the equation:

float force = planet.mass * particle.mass / distanceSquared;

(Thanks Keith Peters!)

Particles are regenerated if they begin shooting off into space. Near the end of the animation, I decrease the center planet’s mass until it becomes negative, changing gravity into repulsion…