a b c d Separation Alignment Avoidance Cohesion Fig 2 Forces that control

# A b c d separation alignment avoidance cohesion fig 2

• 7

This preview shows page 2 - 4 out of 7 pages.

(a) (b) (c) (d) Separation Alignment Avoidance Cohesion Fig. 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 fly in the same direction. To implement this, we sample the heading vectors for the boids in our immediate neighborhood, and compute their average, which we normalize to unit length. We then apply a torque (turning force) to the current boid that pushes it in the direction of this average. Avoidance: Each boid will avoid colliding with fixed obstacles in the scene. At a simplest level, we might imagine that each fixed obstacle generates a repulsive potential field (see Fig. 2(c)). As a boid approaches the object, this repulsive field will tend to cause the boid to deflect its flight path, thus avoiding a collision. The strength of this force grows very rapidly as the boid comes closere to the obstacle. Avoidance can also be applied to predators, which may attack the flock. (It has been theorized that the darting behavior of fish in a school away from a shark has evolved through natural selection, since the sudden 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 each boid towards the center of mass of the flock (see Fig. 2(d)). (In accurate simulations of flocking motion, a boid cannot know exactly where the center of mass is. In general the center of attraction will be some point that the boid perceives being the center of the flock.) Physics-Based Motion: Before getting into the details of how to implement a boids-based motion Lecture 19 2 Spring 2018 CMSC 425 Dave Mount & Roger Eastman system, 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 called numerical physical integration . Let us assume we have n boids, indexed from 1 to n . We also assume that time is discretized into small time units. Let Δ denote the time step. (In Unity, this is the time step used for FixedUpdate and might be chosen to be 1 / 10 of a second.) For example, we start at time t = t 0 = 0, and the j th time step is t j = j Δ. Consider the state of the system at time t . For boid i , let p i ( t ) denote this boid’s current position . This could be represented as the homogeneous coordinates of a point in affine space. Let ~v i ( t ) denote this boid’s current velocity . This could be represented as the homogeneous coordinates of a vector in affine space.  • • • 