Select to expand quote
rp6conrad said..
My algorithm searches only for the highest avg speed over the 500 m distance (actually the speedpoint just before the 500m). Therefore, I will not always have the correct max alfa value . But the cases that a "record" alfa is within a distance much smaller then 500m is rather unlikely !
That may be true for "records", but it is often not true for the best alpha in a session. That depends a lot on how long the runs are, how many jibes are good, how steady the wind is, and if you have alpha markers. Short runs and gusty winds make shorter alphas more likely. Someone who is still working on jibes, or sailing in chop, may have only a few fast jibes per session, which also makes shorter alphas more likely.
Here's an example from a random Lake George session where the best alpha 500 run was only 348.8 m long:

This is from a 39 km session with 40.1 knots top speed in flat water, so this is a relatively good speedsurfer.
For real-time calculations in the watch, fixing the run length to "exactly" 500 meters is also unnecessary, since you already have one end of the range fixed. Instead of iterating over all possible end points, you only need to look at a start point. Compared to post-run analysis of a track, this reduces the computation time by 4 to 5 orders of magnitude. For example, finding alphas from the track above, which has 53 thousand points recorded at 10 Hz, takes about 0.1 seconds on a computer (using only 1 thread, allowing 100-500 m). This looks at 48862 possible end points, and (on average) at 655 possible start points per end point, for a total of about 32 million start-end combinations. With a fixed end point, the algorithm has to look at only 655 points - something an ESP32 certainly certainly can do in a lot less than 0.1 seconds.
The problem with shortcuts like "exactly 500 m", or looking at the COG angle difference, or stopping when the speed drops below 2 knots for a single point, is that they
sometimes fail to give the correct alpha result. These failures are unpredictable, since they depend on the characteristics of the track: "untypical" data will cause failures.
But
these shortcuts are
not necessary. They can be replaced by shortcuts that give
predictable results. For example, tbwonder's limit to 60 seconds means that alphas slower than 16.1 knots (500 m / 60 seconds) are likely be missed, but all faster alphas will
not be be affected (although the algorithm may report lower speed alphas for shorter distances, depending on the exact implementation). In GPS Speedreader, there's a similar maximum time of 194 seconds, which means alphas under 5 knots will not be reported. But Speedreader runs on much faster hardware, so it can look at a larger window.
Besides picking the right shortcuts, avoiding costly and unnecessary calculations is very important, and the original post gives some great examples for that.