refactor!(argus-core): update find_intersection method

Don't separate the intersection finding code into a different trait, as
it can be bundled with interpolation method.
This commit is contained in:
Anand Balakrishnan 2023-09-07 13:28:30 -07:00
parent 3a9623b99b
commit 475d32c533
No known key found for this signature in database
5 changed files with 42 additions and 28 deletions

View file

@ -264,7 +264,7 @@ impl<T> Signal<T> {
pub fn sync_with_intersection<Interp>(&self, other: &Signal<T>) -> Option<Vec<Duration>>
where
T: PartialOrd + Clone,
Interp: FindIntersectionMethod<T>,
Interp: InterpolationMethod<T>,
{
use core::cmp::Ordering::*;
let sync_points: Vec<&Duration> = self.sync_points(other)?.into_iter().collect();
@ -308,7 +308,8 @@ impl<T> Signal<T> {
.interpolate_at::<Interp>(*t)
.map(|value| Sample { time: *t, value }),
};
let intersect = Interp::find_intersection(&a, &b);
let intersect = Interp::find_intersection(&a, &b)
.unwrap_or_else(|| panic!("unable to find intersection for crossing signals"));
return_points.push(intersect.time);
}
}