From 0ae05fd730c45a6b81d09a77c0ebb2b1813cd3bb Mon Sep 17 00:00:00 2001 From: numzero Date: Thu, 13 Jun 2024 15:53:20 +0300 Subject: [PATCH] =?UTF-8?q?Rename=20stuff=20to=20what=20it=20is,=20not=20h?= =?UTF-8?q?ow=20it=E2=80=99s=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/flat/main.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bin/flat/main.rs b/src/bin/flat/main.rs index 3a8c7f5..12e4181 100644 --- a/src/bin/flat/main.rs +++ b/src/bin/flat/main.rs @@ -615,8 +615,8 @@ struct Tube { } impl Tube { - fn fx(&self) -> fns::TubeX { fns::TubeX { min: self.inner_radius, max: self.outer_radius } } - fn fy(&self) -> fns::TubeY { fns::TubeY { internal: self.internal_halflength, external: self.external_halflength } } + fn fx(&self) -> fns::LinearLimiter { fns::LinearLimiter { min: self.inner_radius, max: self.outer_radius } } + fn fy(&self) -> fns::QuadraticAccelerator { fns::QuadraticAccelerator { internal: self.internal_halflength, external: self.external_halflength } } pub fn y(&self, v: f32) -> f32 { self.fy().x(v) } pub fn v(&self, y: f32) -> f32 { self.fy().u(y) } @@ -627,17 +627,17 @@ impl Tube { mod fns { use crate::FloatExt2; - pub struct TubeX { + pub struct LinearLimiter { pub min: f32, pub max: f32, } - impl TubeX { + impl LinearLimiter { pub fn value(&self, x: f32) -> f32 { (self.min, self.max).inverse_lerp(x.abs()).clamp(0.0, 1.0) } pub fn derivative(&self, x: f32) -> f32 { if x.abs() > self.min && x.abs() < self.max { x.signum() / (self.max - self.min) } else { 0.0 } } } - pub struct TubeY { + pub struct QuadraticAccelerator { pub internal: f32, pub external: f32, } @@ -652,7 +652,7 @@ mod fns { if t.abs() <= lim { f(t) } else { val } } - impl TubeY { + impl QuadraticAccelerator { fn a(&self) -> f32 { -(self.external - self.internal) / self.internal.powi(2) } fn b(&self) -> f32 { 2.0 * self.external / self.internal - 1.0 } fn root(&self, x: f32) -> f32 { (self.b().powi(2) + 4.0 * self.a() * x.abs()).sqrt() } @@ -669,8 +669,8 @@ mod fns { use approx::{abs_diff_eq, AbsDiffEq, assert_abs_diff_eq}; #[test] - fn test_tube_x() { - let testee = super::TubeX { min: 20.0, max: 30.0 }; + fn test_linear_limiter() { + let testee = super::LinearLimiter { min: 20.0, max: 30.0 }; let ε = 1.0e-4f32; let δ = 1.0 / 8.0; // Mathematically, you want this to be small. Computationally, you don’t. let margin = 1.0 / 16.0; @@ -695,8 +695,8 @@ mod fns { } #[test] - fn test_tube_y() { - let testee = super::TubeY { internal: 100.0, external: 150.0 }; + fn test_quadratic_accelerator() { + let testee = super::QuadraticAccelerator { internal: 100.0, external: 150.0 }; let ε = 1.0e-4f32; let δ = 1.0 / 8.0; // Mathematically, you want this to be small. Computationally, you don’t. let margin = 1.0 / 16.0;