Greg's Boids page

Greg's boids page

The purpose of this web page is to offer some tips on how to use my boids algorithm for making flocking particles. Last updated July 6, 2000. This algorithm was designed to run under the Persistence of Vision Raytracer, but the basic concept could work with any representation of particles.

How to do it

Here are the steps to follow:
  1. Download my boidread01.txt and boidwrite.txt files. In Netscape Navigator, right click on these URL's, then "Save Link as..." with the extension *.pov in the directory where you store pov files.
  2. Open the boidwrite01.pov file. At around line 19, you will see a command that says:
    #fopen MyFile2 "c:\pov31g\include\boid17awrite04.inc" write
    This command will write an *.INC file into which the positions and velocities of all of your boids will be stored. Edit this line to provide the correct directory path for INC files in your system.
  3. Run, or render the file boidwrite01.pov, with animation turned off.
  4. Set up your system to run for 374 frames.
  5. Run, or render boidread01.pov. (There may be an error message as it renders the last frame, but you will now have 374 images that will make a cool animation of flocking and swarming particles.

What does it do?

1. The following image is a still frame of the animation composed by boidread01.pov. Click on the image to load a 1 MB MPG-1.

2. Here is an animation I submitted to the Internet Raytracing Contest using this concept last year. Click on the image to be brought to the viewing page for this contest. (Mine is the 6th entry, an a 5 MB animation).

3. See several applications of this algorithm at my animation web site:
http://members.xoom.com/gregjohn/animation.html

How does it work?

Craig Reynolds is the pioneer of boids algorithms. He proposed three rules for the operation of flocking particles:
1. Avoid collisions with your neighbor.
2. Seek the center of your flock.
3. Seek to align yourself similarly as your neigbhors.

After playing around with these rules for a while, I found that my particles behaved just as well, perhaps better, if I only gave them two things to worry about:

1. Avoiding collisions with your neighbor.
2. Where it ought to be.
This notion of "where it ought to be" is given a variable name of actave, reminiscent of the time when I was literally following Reynold's advice. The actave is like that mechanical bunny they use at dog race tracks to motivate the dogs to run faster. Every dog would spend every second with that mechanical bunny in its mouth except for:
  1. The need to avoiding collisions other dogs.
  2. The effects of inertia as it rounds corners, inability but to run so fast, lack of foreknowledge (they're just dogs, remember) of where that bunny will go next).

A visual approach

Consider the forces acting on a single actor, the green particle #1 in a field of just four particles.

Every actor exerts a repulsive force on particle #1, inversely proportional to the distance.

Adding all of the forces together gives a resultant vector.

Now consider the actave particle, the white bunny the actors want to chase. It exerts an attractive force on the actor,

Adding the attractive and repulsive forces (with different scalars to your taste) yields the new force (in green) that acts on particle #1 in this time frame. A new velocity and position are thereby calculated for the given time element. Remember:

a= f/m (The acceleration of a particle is proportional to the force acting on it )
dv= a dt (Acceleration is the change in velocity per time increment)
dp= v dt (The change in position is the velocity times the time increment)


Other tricks to try

Actave can be a stationary point, giving one swarm-like behavior. Actave can be the same for all actors or uniquely defined for each actor. A chain could be formed if the actave of each particle were defined as the position of the n+1th particle:
#declare actave=actorp[mod(n+1,num-1)];

You could make each particle have a constant speed:
#declare actorv[n]=constant1*vnormalize(actorv[n];

You could make each particle have a constant acceleration:
#declare a1=constant2*vnormalize(a1);

Experiment and enjoy. Copyright 2000 Greg M. Johnson.

Email me at:
pterandon at yahoo dot com .

OTHER LINKS

MUST VISIT LINKS
Viewable with any browser | Sola Scriptura | Global Warming is Here | Astronomy Picture of the Day | Coolest TV Show Ever | Listen To My Station | Violence begets the very thing it seeks to destroy | The witnesses changed their stories under police pressure | Stop telemarketers cold! | The Rainforest Site | Save the Oceans at your Dinner Table! | Tricked my father, Killed him... | Political news from Doonesbury | "Throat scratch, yes.Pain-in-the-neck old agressive malignant growths, no!" | Who's polluting your groundwater? | Relativity proves OT Creator | Watch those yolks, folks! | Save Family Farms | Give Sulu a ship! | Burn All Gifs | Cartoon links on the web | Just killin' babies | Saving Kids

MUST SEE COMPUTER ART
Cool fractal programs | 3D Artists - Art Gallery | Cool raytracing program

MUST READ BOOKS
On Being a Theologian of the Cross | Cost of Discipleship | Mere Christianity | Dinosaur Heresies | Dechronization of Sam Magruder | Guns of the South

MY LINKS
[ Animation| Endorsements | Dihydrogen Monoxide | Economics | Smoking | Fishing |Woodstock '94 | Social Gospel | AboutMe AboutMe ]