igc-xc-score
igc-xc-score copied to clipboard
Moving average / flight detection
I think that the moving average could be implemented much more efficiently by only adding the new point and removing the old from a long running sum instead of recomputing the complete sum for every single point.
I think there is also a bug as the sums get divided by the number of samples instead of the time.
It would be great if the flight definitions are passed as an argument instead of using global variables.
Maybe it would be nice to move this code to a separate library ?
All the points are valid :smile: But the launch/landing detection is not on the time critical path, this will be barely noticeable I think I will leave this for an eventual 1.7
I stumbled across the flight detection:
const definitionFlight = {
t: 60,
x0: 1.5,
xt: 5,
z0: 0.05,
zt: 0.9
};
What does xt and zt mean? It's not described in he comment of the file.
t
would imply time but in the code it's compared to hma
& vma
which would not make sense if it's a time value.
What am I missing?
Launch detection requires that the horizontal and vertical moving averages raise above xt
/zt
and then stay above x0
/z0
for at least t
seconds - the launch is considered to have happened at the xt
/zt
.
It is probably t
for threshold or maybe t
for take-off - I don't remember anymore.
Thanks for clearing things up!