Fix voltage spike at segment boundaries in smooth plot mode
In smooth (rise-time) mode, drawSampledWave samples totalVoltageAt at
evenly-spaced z values including exact boundary points (e.g. z=0.5 for
N=2 segments). At those points both the ending wave of the left segment
and the starting wave of the right segment passed the ±1e-9 range checks
in waveVoltageAt, doubling the displayed voltage — a visible spike.
Fix: add segmentForZ(z, N) which maps each sample to its owning segment,
and filter launchedWaves in totalVoltageAt to only sum waves whose segIdx
matches. The +1e-9 nudge in segmentForZ handles floating-point imprecision
when z lands exactly on a boundary (e.g. 200/400 = 0.5 exactly).
The bug was absent in step mode because totalSegmentsForWaves uses midpoints
between breakpoints, never probing the exact boundary z. It was also subtle
with 3 segments (boundary at 1/3) since 1/3·400 is never an integer.
Adds two regression tests that directly catch the spike.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>