• facebook
  • twitter
  • linkedin
  • instagram

Flocking with Sperm

by Taylor

8th December, 2015

Flocking. Sperm. Sperm flocking.That got you to click didn’t it? Everybody loves sperm! Well, if you don’t you’ve got to at least acknowledge it’s an integral building block of human life. Good news, you’ll get to see some sperm below. Bad news, it’s not all that erotic. Now, back to sperm flocking. What does that mean. Well, flocking is a behavior exhibited by birds. The behavior was formalized into an algorithm and simulated on a machine by Craig Reynolds in 1987.

The layperson knows what it means to flock. You’d be hard pressed to find a person that hasn’t heard the saying

Birds of a feather flock together

or knows what it looks like when beards flock. But the average person cannot describe to you what it means for a bird to flock. They cannot formulate the characteristics of flocking flight as opposed to regular flight.

Well, I’ll do my best to explain it, not that much of this information is pulled  from Craig Reynolds website.

Flocking

Flocking behavior has three key tenants:

  1. Separation
  2. Alignment
  3. Cohesion

 Separation

Separation states that a bird will steer itself so as to avoid crowding fellow flockmates.

Given a radius, a bird (or boid as coined by Reynolds original software) will head in the opposite direction of the summation of the vectors generated by calculation the distance from each other flockmate in the bird / boid’s neighborhood. The red vector is the delta velocity vector calculated based on the other boids in the neighborhood.

Alignment

Alignment states that the boid will steer towards the average heading of local flockmates. Below is the delta velocity vector generated based on the heading of the other flockmates in the neighborhood..

Source: http://www.red3d.com/cwr/boids/

Cohesion

Cohesion states that a boid will steer to move toward the average position of local flockmates.

Source: http://www.red3d.com/cwr/boids/

Here the delta velocity vector steers the boid towards the center of the position of flockmates in our boids neighborhood.

Sperm

Below I took Mike Bostock up on his challenge to add Boids flocking algorithm in with his Spermatozoon visualization.

Swimming

Below we see the sperm as they exist peacefully without any applied flocking algorithm.

Flocking

Now we have my added flocking code. Note that the sperm head transform is broken and needs to be fixed. You can see how the sperm flock in groups, stay separated from one another and yet align their headings to those of their nearest neighbors.

Sources:
https://en.wikipedia.org/wiki/Flocking_(behavior)
http://gamedevelopment.tutsplus.com/tutorials/the-three-simple-rules-of-flocking-behaviors-alignment-cohesion-and-separation–gamedev-3444
http://paperjs.org/examples/tadpoles/
http://bl.ocks.org/mbostock/1136236


by Taylor