From b6f705eb019f085c3313a32a549b593d261e5ae2 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Tue, 4 Nov 2025 10:49:56 +0100 Subject: [PATCH] Add interpolation method for discrete events --- argus/src/core/signals/interpolation.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/argus/src/core/signals/interpolation.rs b/argus/src/core/signals/interpolation.rs index 9a5ef46..4119283 100644 --- a/argus/src/core/signals/interpolation.rs +++ b/argus/src/core/signals/interpolation.rs @@ -28,6 +28,28 @@ impl InterpolationMethod for Constant { } } +/// Fixed Value interpolation. +/// +/// If the signal does not have a value at a given point, a fixed value is returned +pub struct DefaultFalse; + +impl InterpolationMethod for DefaultFalse { + fn at(a: &Sample, b: &Sample, time: Duration) -> Option { + if time == b.time { + Some(b.value.clone()) + } else if a.time <= time && time < b.time { + Some(a.value.clone()) + } else { + Some(false) + } + } + + fn find_intersection(_a: &Neighborhood, _b: &Neighborhood) -> Option> { + // The signals must be either constant or colinear. Thus, return None. + None + } +} + /// Nearest interpolation. /// /// Here, the signal value from the nearest sample (time-wise) is propagated to the