Empirical measurement of each wave's period - the x-distance over which
Waves.wave(x) repeats itself. Used to close curved shapes
cleanly: if the total x-sweep is an integer multiple of the period,
endShape(CLOSE) draws a zero-length line.
Waves.wave(x, { wave: idx, t: 0, amplitude: 1 }) - amplitude: 1 forces normalized [-1, 1] output (the library default amplitude is 100), so the thresholds below are formula-agnostic.wave(x) twice at the same x. If results differ, the wave is marked non-deterministic (p5's random() advances internal state).wave(x) and wave(x + T) at 80 sample points in x ∈ [10, 110]. Smallest T where mean error < 0.002 AND multiples 2T, 3T also match is the detected period.|wave(10) - wave(10 + T)| as a final sanity check.