function steerForFlock (out, boid, flock) {
    const separationRadius =  50.0
    //const separationAngle  = -0.707
    const separationFieldOfView = 135
    const separationWeight =  12.0

    const alignmentRadius = 60
    //const alignmentAngle  = 0.7
    const alignmentFieldOfView = 46
    const alignmentWeight = 8.0

    const cohesionRadius = 20
    //const cohesionAngle  = -0.15
    const cohesionFieldOfView = 99
    const cohesionWeight = 8.0

    const maxRadius = Math.max(separationRadius, alignmentRadius, cohesionRadius)

    // determine each of the three component behaviors of flocking
    const separation = steerForSeparation([ 0, 0 ], boid, separationRadius, separationFieldOfView, flock)

    const alignment  = steerForAlignment([ 0, 0 ], boid, alignmentRadius, alignmentFieldOfView, flock)
    
    const cohesion   = steerForCohesion([ 0, 0 ], boid, cohesionRadius, cohesionFieldOfView, flock)

    // apply weights to components (save in variables for annotation)
    const separationW = vec2.scale([ 0, 0 ], separation, separationWeight)
    const alignmentW = vec2.scale([ 0, 0 ], alignment, alignmentWeight)
    const cohesionW = vec2.scale([ 0, 0 ], cohesion, cohesionWeight)

    vec2.add(out, separationW, alignmentW)
    return vec2.add(out, out, cohesionW) 
}
// group of boids loosely move together
group of boids loosely move together
group of boids loosely move together
function steerForFlock (out, boid, flock) {
    const separationRadius =  50.0
    const separationFieldOfView = 135
    const separationWeight =  12.0
    const alignmentRadius = 60
    const alignmentFieldOfView = 46
    const alignmentWeight = 8.0
    const cohesionRadius = 20
    const cohesionFieldOfView = 99
    const cohesionWeight = 8.0
    const maxRadius = Math.max(separationRadius, alignmentRadius, cohesionRadius)
    const separation = steerForSeparation([ 0, 0 ], boid, separationRadius, separationFieldOfView, flock)
    const alignment  = steerForAlignment([ 0, 0 ], boid, alignmentRadius, alignmentFieldOfView, flock)
    const cohesion   = steerForCohesion([ 0, 0 ], boid, cohesionRadius, cohesionFieldOfView, flock)
    const separationW = vec2.scale([ 0, 0 ], separation, separationWeight)
    const alignmentW = vec2.scale([ 0, 0 ], alignment, alignmentWeight)
    const cohesionW = vec2.scale([ 0, 0 ], cohesion, cohesionWeight)
    vec2.add(out, separationW, alignmentW)
    return vec2.add(out, out, cohesionW) 
}
function steerForFlock ( out , boid , flock ) { const separationRadius = 50.0 const separationFieldOfView = 135 const separationWeight = 12.0 const alignmentRadius = 60 const alignmentFieldOfView = 46 const alignmentWeight = 8.0 const cohesionRadius = 20 const cohesionFieldOfView = 99 const cohesionWeight = 8.0 const maxRadius = Math . max ( separationRadius , alignmentRadius , cohesionRadius ) const separation = steerForSeparation ( [ 0 , 0 ] , boid , separationRadius , separationFieldOfView , flock ) const alignment = steerForAlignment ( [ 0 , 0 ] , boid , alignmentRadius , alignmentFieldOfView , flock ) const cohesion = steerForCohesion ( [ 0 , 0 ] , boid , cohesionRadius , cohesionFieldOfView , flock ) const separationW = vec2 . scale ( [ 0 , 0 ] , separation , separationWeight ) const alignmentW = vec2 . scale ( [ 0 , 0 ] , alignment , alignmentWeight ) const cohesionW = vec2 . scale ( [ 0 , 0 ] , cohesion , cohesionWeight ) vec2 . add ( out , separationW , alignmentW ) return vec2 . add ( out , out , cohesionW ) }
group of boids loosely move together
group of boids loosely move together
//const separationAngle  = -0.707 //const alignmentAngle  = 0.7 //const cohesionAngle  = -0.15 // determine each of the three component behaviors of flocking // apply weights to components (save in variables for annotation)