Stimulus: replace Gated
with a type alias
This commit is contained in:
@@ -477,7 +477,7 @@ pub trait StimExt<R>: Sized {
|
||||
Shifted::new(self, new_start)
|
||||
}
|
||||
fn gated(self, from: R, to: R) -> Gated<R, Self> {
|
||||
Gated::new(self, from, to)
|
||||
Gated::new(Pulse::new(from, to), self)
|
||||
}
|
||||
fn scaled<T: TimeVarying<R>>(self, scale: T) -> Scaled<Self, T> {
|
||||
Scaled::new(self, scale)
|
||||
@@ -552,11 +552,11 @@ impl<R: Real> Sinusoid<R> {
|
||||
}
|
||||
pub fn one_cycle(self) -> Gated<R, Self> {
|
||||
let wl = self.wavelength();
|
||||
Gated::new(self, R::zero(), wl)
|
||||
self.gated(R::zero(), wl)
|
||||
}
|
||||
pub fn half_cycle(self) -> Gated<R, Self> {
|
||||
let wl = self.wavelength();
|
||||
Gated::new(self, R::zero(), R::half() * wl)
|
||||
self.gated(R::zero(), R::half() * wl)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,28 +623,7 @@ impl<R: Real> TimeVarying<R> for Pulse<R> {
|
||||
}
|
||||
|
||||
|
||||
// TODO: this can be replaced with a ModulatedVectorField
|
||||
#[derive(Clone)]
|
||||
pub struct Gated<R, T> {
|
||||
active: Pulse<R>,
|
||||
inner: T,
|
||||
}
|
||||
|
||||
impl<R, T> Gated<R, T> {
|
||||
pub fn new(inner: T, start: R, end: R) -> Self {
|
||||
Self { inner, active: Pulse::new(start, end) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: Real, T: TimeVarying<R>> TimeVarying<R> for Gated<R, T> {
|
||||
fn at(&self, t_sec: R) -> FieldMags<R> {
|
||||
if self.active.contains(t_sec) {
|
||||
self.inner.at(t_sec)
|
||||
} else {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
pub type Gated<R, T> = Scaled<Pulse<R>, T>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Shifted<R, T> {
|
||||
|
Reference in New Issue
Block a user