add a RenderedVectorField
. maybe more accurately called a rendered stimulus?
used to represent a stimulus which has been rendered for a specific time with specific simulation parameters.
This commit is contained in:
@@ -153,6 +153,52 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RenderedVectorField {
|
||||
e: DimSlice<Vec<Vec3<f32>>>,
|
||||
h: DimSlice<Vec<Vec3<f32>>>,
|
||||
scale: f32,
|
||||
feature_size: f32,
|
||||
t_sec: f32,
|
||||
}
|
||||
|
||||
impl RenderedVectorField {
|
||||
pub fn new(
|
||||
e: DimSlice<Vec<Vec3<f32>>>,
|
||||
h: DimSlice<Vec<Vec3<f32>>>,
|
||||
scale: f32,
|
||||
feature_size: f32,
|
||||
t_sec: f32,
|
||||
) -> Self {
|
||||
Self { e, h, scale, feature_size, t_sec }
|
||||
}
|
||||
pub fn e<'a>(&'a self) -> DimSlice<&'a [Vec3<f32>]> {
|
||||
self.e.as_ref()
|
||||
}
|
||||
pub fn h<'a>(&'a self) -> DimSlice<&'a [Vec3<f32>]> {
|
||||
self.h.as_ref()
|
||||
}
|
||||
pub fn scale(&self) -> f32 {
|
||||
self.scale
|
||||
}
|
||||
pub fn feature_size(&self) -> f32 {
|
||||
self.feature_size
|
||||
}
|
||||
pub fn time(&self) -> f32 {
|
||||
self.t_sec
|
||||
}
|
||||
}
|
||||
|
||||
impl VectorField for RenderedVectorField {
|
||||
fn at(&self, _feat_size: f32, loc: Index) -> Fields {
|
||||
Fields::new_eh(self.e[loc.into()], self.h[loc.into()])
|
||||
}
|
||||
}
|
||||
impl Stimulus for RenderedVectorField {
|
||||
fn at(&self, _t_sec: f32, _feat_size: f32, loc: Index) -> Fields {
|
||||
Fields::new_eh(self.e[loc.into()], self.h[loc.into()])
|
||||
}
|
||||
}
|
||||
|
||||
impl Stimulus for Fields {
|
||||
fn at(&self, _t_sec: f32, _feat_size: f32, _loc: Index) -> Fields {
|
||||
*self
|
||||
@@ -422,16 +468,24 @@ impl TimeVarying for FieldMags {
|
||||
// assumed to represent the E field
|
||||
impl TimeVarying for f32 {
|
||||
fn at(&self, _t_sec: f32) -> FieldMags {
|
||||
FieldMags { e: *self, h: 0.0 }
|
||||
FieldMags::new_e(*self)
|
||||
}
|
||||
}
|
||||
|
||||
// Vec<T> at any `t_sec` behaves as the sum of all its components at that time.
|
||||
impl<T: TimeVarying> TimeVarying for Vec<T> {
|
||||
fn at(&self, t_sec: f32) -> FieldMags {
|
||||
self.iter().fold(FieldMags::default(), |acc, i| acc + i.at(t_sec))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UnitEH;
|
||||
impl TimeVarying for UnitEH {
|
||||
fn at(&self, _t_sec: f32) -> FieldMags {
|
||||
FieldMags::new_eh(1.0, 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// E field which changes magnitude sinusoidally as a function of t
|
||||
#[derive(Clone)]
|
||||
pub struct Sinusoid {
|
||||
|
Reference in New Issue
Block a user