pub trait FloatExt {
// Required methods
fn lerp(self, other: f32, t: f32) -> f32;
fn clamp(self, min: f32, max: f32) -> f32;
fn map_range(
self,
in_min: f32,
in_max: f32,
out_min: f32,
out_max: f32,
) -> f32;
fn deadzone(self, deadzone: f32) -> f32;
fn snap(self, step: f32) -> f32;
}Expand description
Extension trait for f32 with game-oriented helpers.
Required Methods§
Sourcefn lerp(self, other: f32, t: f32) -> f32
fn lerp(self, other: f32, t: f32) -> f32
Linear interpolation between self and other by t (clamped 0..1).
Sourcefn map_range(self, in_min: f32, in_max: f32, out_min: f32, out_max: f32) -> f32
fn map_range(self, in_min: f32, in_max: f32, out_min: f32, out_max: f32) -> f32
Map value from in_min..=in_max to out_min..=out_max.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".