Fix: off-by-one in the boid count enumeration

`enumerate()` begins counting at 0, so I was dividing the sum by one
less than the count of boids. Thus the over-expanded result.

I should do unit testing.

I should rewrite this function to take the vector directly. I *know*
that the input is a vector at all times. Mmh.
This commit is contained in:
2024-07-11 14:13:07 -05:00
parent a0d2e2b467
commit ac25a41f77

View File

@@ -226,8 +226,8 @@ pub(crate) fn center_of_boids(points: impl Iterator<Item = Vec2>) -> Option<Vec2
// add running sum & new point for new running sum // add running sum & new point for new running sum
(idx, sum + point) (idx, sum + point)
}); });
let avg = sum / ((len + 1) as f32);
let avg = sum / (len as f32);
Some(avg) Some(avg)
} }