* @brief Computes the sweep origin, interpolating the exact level crossing on an edge. */
| 727 | * @brief Computes the sweep origin, interpolating the exact level crossing on an edge. |
| 728 | */ |
| 729 | [[nodiscard]] double triggerOrigin(double now, double value) const |
| 730 | { |
| 731 | if (!edgeDetected(value)) |
| 732 | return now; |
| 733 | |
| 734 | const double denom = value - prevValue; |
| 735 | double frac = (std::abs(denom) > 1e-12) ? (level - prevValue) / denom : 0.0; |
| 736 | frac = std::clamp(frac, 0.0, 1.0); |
| 737 | return prevTime + frac * (now - prevTime); |
| 738 | } |
| 739 | |
| 740 | /** |
| 741 | * @brief Publishes the filled sweep to `front` and ends the acquisition. `lastSweepSec` is |