fn clamp_boid_speed(boids: &mut System<Boid>, max_speed: f64) {
        boids
            .apply(|boid|{
                let heading = boid.mut_heading();
                let speed = heading.length();
                // The speed can't exceed the max speed.
                if speed > max_speed {
                    heading.set_length(max_speed);
                }
            });
    }
/// Prevents the speed of the boids from exceeding a specific value.
Prevents the speed of the boids from exceeding a specific value.
Prevents the speed of the boids from exceeding a specific value .
fn clamp_boid_speed(boids: &mut System<Boid>, max_speed: f64) {
        boids
            .apply(|boid|{
                let heading = boid.mut_heading();
                let speed = heading.length();
                // The speed can't exceed the max speed.
                if speed > max_speed {
                    heading.set_length(max_speed);
                }
            });
    }
fn clamp_boid_speed ( boids : & mut System < Boid > , max_speed : f64 ) { boids . apply ( | boid | { let heading = boid . mut_heading ( ) ; let speed = heading . length ( ) ; // The speed can't exceed the max speed. if speed > max_speed { heading . set_length ( max_speed ) ; } } ) ; }
Prevents the speed of the boids from exceeding a specific value.
Prevents the speed of the boids from exceeding a specific value .
boids
&mut System<Boid>
max_speed
f64
boids
&mut System<Boid>
max_speed
f64