CurlStimulus: re-use the HasCrossSection trait code

i believe this inverts the sign, but it also looks more correct this way
so i'm not immediately correcting that in this patch.
will backfill tests to verify.
This commit is contained in:
2022-08-09 22:14:38 -07:00
parent 1771973c6d
commit 520e9d9f68

View File

@@ -1,6 +1,6 @@
use crate::real::*; use crate::real::*;
use crate::cross::vec::Vec3; use crate::cross::vec::Vec3;
use crate::geom::{Meters, Region, Torus}; use crate::geom::{HasCrossSection as _, Meters, Region, Torus};
use rand; use rand;
/// field densities /// field densities
@@ -162,12 +162,8 @@ impl<R, T> CurlStimulus<R, T> {
impl<T: TimeVarying1 + Sync> AbstractStimulus for CurlStimulus<Torus, T> { impl<T: TimeVarying1 + Sync> AbstractStimulus for CurlStimulus<Torus, T> {
fn at(&self, t_sec: f32, pos: Meters) -> Fields { fn at(&self, t_sec: f32, pos: Meters) -> Fields {
if self.region.contains(pos) { if self.region.contains(pos) {
let center = self.region.center();
let axis = self.region.axis();
let FieldMags { e, h } = self.stim.at(t_sec); let FieldMags { e, h } = self.stim.at(t_sec);
let from_center_to_point = *pos - *center; let rotational = self.region.cross_section_normal(pos).norm();
// TODO: is this inverted?
let rotational = from_center_to_point.cross(*axis);
let impulse_e = rotational.with_mag(e.cast()).unwrap_or_default(); let impulse_e = rotational.with_mag(e.cast()).unwrap_or_default();
let impulse_h = rotational.with_mag(h.cast()).unwrap_or_default(); let impulse_h = rotational.with_mag(h.cast()).unwrap_or_default();
Fields { Fields {