Initial velocity calculation uses the wrong indices
This was pointed out by Simon Thum, introduced by commit 7d06ccc0. Discussion was in email, but this is my analysis:
Trackers are a set of deltas to the current point, including time and direction. trackers[0]
is 0/0
, trackers[2]
is the delta to point 2 events ago. Velocity is simply that tracker's delta/time.
For up to trackers[2]
, we use the velocity of that event as initial velocity. But that's wrong, after 6 events we would use event 4 as initial velocity after than actual event 2. I suspect my mistake was taking offset[2]
as the second event rather than the event 2 events ago.
Before this patch, initial_velocity
was always velocity[tracker[1]]
. The fix to get the intended behaviour would be to use something like (tracker->ntrackers - 2)
instead, but only for result
, not initial_velocity
.
Additional problem: we don't have a notion of "the first two events" as 7d06ccc0 wants it, the trackers are just a continuous buffer. No automatic reset after a timeout is present.