FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    MaterialSpringSpec

    struct · ferroui-themes-material · v0.5.0

    struct MaterialSpringSpec
    

    Parameters of a unit-mass damped spring: x'' + 2 ζ √k x' + k (x-target) = 0.

    View source

    Members

    new

    const fn new(damping_ratio: f64, stiffness: f64) -> Self
    

    Creates a spring. Stiffness must be positive and finite; damping must be finite and nonnegative. A zero-damping spring oscillates forever and has no settling duration.

    Source

    damping_ratio

    const fn damping_ratio(self: Self) -> f64
    

    Source

    stiffness

    const fn stiffness(self: Self) -> f64
    

    Source

    sample

    fn sample(self: Self, elapsed: f64, from: f64, target: f64, initial_velocity: f64) -> MaterialSpringSample
    

    Evaluates both position and velocity analytically, independent of display refresh rate.

    All three damping regimes are supported. The overdamped case uses a stable slow root and expm1 to avoid subtracting nearly equal exponentials near critical damping. The underdamped case uses sinc, so its limit at critical damping is also well behaved. A negative/NaN elapsed time leaves the initial state unchanged; positive infinity is treated as the settled state. Initial and target values must be finite.

    Source

    settling_duration

    fn settling_duration(self: Self) -> f64
    

    A conservative finite tail for the unit step, with position tolerance 0.001 and velocity tolerance 0.001 * sqrt(stiffness). Returns infinity for an undamped spring.

    Source

    settling_duration_from

    fn settling_duration_from(self: Self, displacement: f64, velocity: f64, position_threshold: f64, velocity_threshold: f64) -> f64
    

    A conservative settling time for an arbitrary interrupted spring, in seconds.

    Both the position and velocity stay below their respective tolerances after this time. Unlike the unit-step adapter, this accounts for momentum when the new target is very close to the current position. Bounds are analytical exponential envelopes; this does not advance a simulation or mistake an oscillation's zero crossing for rest.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • ErasedDestructor
    • IntoEither
    • CastableFrom<ST, Uninit, Uninit>
    • CastableFrom<ST, Initialized, Initialized>
    • Read<Exclusive, BecauseExclusive>
    • Clone
    • Copy
    • Debug
    • StructuralPartialEq
    • PartialEq

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.