function avoidCollisionSpeed(boid){
	// Get surrounding boids
	let surrounding_boids = surroundingBoids(boid, surrounding_distance)
	let speedVector = new THREE.Vector3(0,0,0)
	let boidPosition = new THREE.Vector3(boid.position.x,boid.position.y,boid.position.z)
	var currentBoidPosition
	for (let i=0;i<surrounding_boids.length;i++){
		currentBoid = surrounding_boids[i]
		currentBoidPosition = new THREE.Vector3(currentBoid.position.x,currentBoid.position.y,currentBoid.position.z)
		speedVector.add(boidPosition.clone().addScaledVector(currentBoidPosition,-1))
	}
	return [speedVector.normalize(),surrounding_boids]
}
// Second Rule : avoid collisions bewteen boids
Second Rule : avoid collisions bewteen boids
Second Rule : avoid collisions bewteen boids
function avoidCollisionSpeed(boid){
	let surrounding_boids = surroundingBoids(boid, surrounding_distance)
	let speedVector = new THREE.Vector3(0,0,0)
	let boidPosition = new THREE.Vector3(boid.position.x,boid.position.y,boid.position.z)
	var currentBoidPosition
	for (let i=0;i<surrounding_boids.length;i++){
		currentBoid = surrounding_boids[i]
		currentBoidPosition = new THREE.Vector3(currentBoid.position.x,currentBoid.position.y,currentBoid.position.z)
		speedVector.add(boidPosition.clone().addScaledVector(currentBoidPosition,-1))
	}
	return [speedVector.normalize(),surrounding_boids]
}
function avoidCollisionSpeed ( boid ) { let surrounding_boids = surroundingBoids ( boid , surrounding_distance ) let speedVector = new THREE . Vector3 ( 0 , 0 , 0 ) let boidPosition = new THREE . Vector3 ( boid . position . x , boid . position . y , boid . position . z ) var currentBoidPosition for ( let i = 0 ; i < surrounding_boids . length ; i ++ ) { currentBoid = surrounding_boids [ i ] currentBoidPosition = new THREE . Vector3 ( currentBoid . position . x , currentBoid . position . y , currentBoid . position . z ) speedVector . add ( boidPosition . clone ( ) . addScaledVector ( currentBoidPosition , - 1 ) ) } return [ speedVector . normalize ( ) , surrounding_boids ] }
Second Rule : avoid collisions bewteen boids
Second Rule : avoid collisions bewteen boids
// Get surrounding boids