Skip to content

Commit

Permalink
fix(flocking): remove center of mass
Browse files Browse the repository at this point in the history
  • Loading branch information
tolstenko committed Aug 28, 2023
1 parent 3f438c0 commit a97f2ea
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions examples/flocking/behaviours/CohesionRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ Vector2f CohesionRule::computeForce(const std::vector<Boid*>& neighborhood, Boid
// hint: iterate over the neighborhood

// find center of mass
Vector2f centerOfMass = Vector2f::zero();
for (auto b : neighborhood) centerOfMass += b->getPosition(); // accumulate positions
centerOfMass /= neighborhood.size(); // divide by number of boids

cohesionForce = centerOfMass - boid->getPosition(); // direction force towards center of mass

return cohesionForce;
}

0 comments on commit a97f2ea

Please sign in to comment.