pub struct LogMapper { /* private fields */ }Expand description
Logarithmic range mapping.
Maps values logarithmically between the range endpoints. Suitable for frequency parameters where perceptual response is logarithmic.
§Panics
Panics if the range contains zero or negative values, as logarithm is undefined for non-positive numbers.
§Example
ⓘ
let mapper = LogMapper::new(20.0..=20000.0);
// Geometric mean is at normalized 0.5
let mid = mapper.denormalize(0.5);
assert!((mid - 632.45).abs() < 1.0); // sqrt(20 * 20000)Implementations§
Trait Implementations§
Source§impl RangeMapper for LogMapper
impl RangeMapper for LogMapper
Source§fn normalize(&self, plain: f64) -> f64
fn normalize(&self, plain: f64) -> f64
Convert a plain value to normalized (0.0-1.0). Read more
Source§fn denormalize(&self, normalized: f64) -> f64
fn denormalize(&self, normalized: f64) -> f64
Convert a normalized value (0.0-1.0) to plain. Read more
Source§fn default_normalized(&self, plain_default: f64) -> f64
fn default_normalized(&self, plain_default: f64) -> f64
Get the default normalized value for a given plain default.
Auto Trait Implementations§
impl Freeze for LogMapper
impl RefUnwindSafe for LogMapper
impl Send for LogMapper
impl Sync for LogMapper
impl Unpin for LogMapper
impl UnwindSafe for LogMapper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more