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:
@@ -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
|
||||
(idx, sum + point)
|
||||
});
|
||||
let avg = sum / ((len + 1) as f32);
|
||||
|
||||
let avg = sum / (len as f32);
|
||||
Some(avg)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user