// flock based on it's neighbors
// returns the x and y components of resultant vector
flock based on it's neighbors
returns the x and y components of resultant vector
flock based on it ' s neighbors returns the x and y components of resultant vector
fn flock(&self, boids: &[Boid]) -> (f64, f64) {
        let alignment = self.align(&boids);
        let cohesion = self.cohere(&boids);
        let separation = self.separate(&boids);
        let mut vx = self.vx + alignment.0 * ALIGNMENT_WEIGHT + cohesion.0 * COHESION_WEIGHT + separation.0 * SEPARATION_WEIGHT;
        let mut vy = self.vy + alignment.1 * ALIGNMENT_WEIGHT + cohesion.1 * COHESION_WEIGHT + separation.1 * SEPARATION_WEIGHT;
        vx = self.limit_speed(vx);
        vy = self.limit_speed(vy);
        (vx, vy)
    }
fn flock ( & self , boids : & [ Boid ] ) -> ( f64 , f64 ) { let alignment = self . align ( & boids ) ; let cohesion = self . cohere ( & boids ) ; let separation = self . separate ( & boids ) ; let mut vx = self . vx + alignment . 0 * ALIGNMENT_WEIGHT + cohesion . 0 * COHESION_WEIGHT + separation . 0 * SEPARATION_WEIGHT ; let mut vy = self . vy + alignment . 1 * ALIGNMENT_WEIGHT + cohesion . 1 * COHESION_WEIGHT + separation . 1 * SEPARATION_WEIGHT ; vx = self . limit_speed ( vx ) ; vy = self . limit_speed ( vy ) ; ( vx , vy ) }
flock based on it's neighbors
returns the x and y components of resultant vector
flock based on it ' s neighbors returns the x and y components of resultant vector
&self
boids
&[Boid]