(a)(b)(c)(d)SeparationAlignmentAvoidanceCohesionFig. 2: Forces that control flocking behavior.Alignment:Each boid’s direction of flight is aligned with nearby boids (see Fig. 2(b)). Thus,local clusters of boids will tend to point in the same direction and hence will tend to flyin the same direction. To implement this, we sample the heading vectors for the boidsin our immediate neighborhood, and compute their average, which we normalize to unitlength. We then apply a torque (turning force) to the current boid that pushes it in thedirection of this average.Avoidance:Each boid will avoid colliding with fixed obstacles in the scene. At a simplestlevel, we might imagine that each fixed obstacle generates a repulsive potential field (seeFig. 2(c)). As a boid approaches the object, this repulsive field will tend to cause theboid to deflect its flight path, thus avoiding a collision. The strength of this force growsvery rapidly as the boid comes closere to the obstacle. Avoidance can also be applied topredators, which may attack the flock. (It has been theorized that the darting behaviorof fish in a school away from a shark has evolved through natural selection, since thesudden chaotic motion of many fish can confuse the predator.)Cohesion:Effects such as avoidance can cause the flock to break up into smaller subflocks.To simulate the flocks tendency to regroup, there is a force that tends to draw eachboid towards the center of mass of the flock (see Fig. 2(d)). (In accurate simulations offlocking motion, a boid cannot know exactly where the center of mass is. In general thecenter of attraction will be some point that the boid perceives being the center of theflock.)Physics-Based Motion:Before getting into the details of how to implement a boids-based motionLecture 192Spring 2018
CMSC 425Dave Mount & Roger Eastmansystem, it is useful to see how we can apply physical forces to induce a motion-planning system.We discussed this briefly in the context of potential-field methods in an earlier lecture. Here,we consider it in the context of a computational process callednumerical physical integration.Let us assume we havenboids, indexed from 1 ton. We also assume that time is discretizedinto small time units. Let Δ denote the time step. (In Unity, this is the time step used forFixedUpdateand might be chosen to be 1/10 of a second.)For example, we start at timet=t0= 0, and thejth time step istj=jΔ.Consider the state of the system at timet.For boidi, letpi(t) denote this boid’scurrent position.This could be represented asthe homogeneous coordinates of a point in affine space. Let~vi(t) denote this boid’scurrentvelocity. This could be represented as the homogeneous coordinates of a vector in affine space.