CurrentLoop: factor out the tangent calculation
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::geom::{Meters, Region, Torus, WorldRegion};
|
||||
use crate::geom::{HasTangent as _, Meters, Region, Torus, WorldRegion};
|
||||
use crate::real::{Real as _, ToFloat as _};
|
||||
use crate::cross::vec::{Vec3, Vec3u};
|
||||
use crate::sim::AbstractSim;
|
||||
@@ -309,7 +309,7 @@ impl<S: AbstractSim> AbstractMeasurement<S> for Current {
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct CurrentLoop {
|
||||
name: String,
|
||||
region: Torus
|
||||
region: Torus,
|
||||
}
|
||||
|
||||
impl CurrentLoop {
|
||||
@@ -321,9 +321,7 @@ impl CurrentLoop {
|
||||
}
|
||||
fn data<S: AbstractSim>(&self, state: &S) -> f32 {
|
||||
let FieldSample(volume, directed_current, _current_vec) = state.map_sum_over_enumerated(&self.region, |coord: Meters, _cell| {
|
||||
let normal = self.region.axis();
|
||||
let to_coord = *coord - *self.region.center();
|
||||
let tangent = normal.cross(to_coord).norm();
|
||||
let tangent = self.region.tangent(coord);
|
||||
let current = state.current(coord);
|
||||
let directed_current = current.dot(tangent.cast());
|
||||
FieldSample(1, directed_current.cast(), current.cast())
|
||||
|
Reference in New Issue
Block a user