# MaterialSpringSpec

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-themes-material/motion/struct-materialspringspec/

**struct** · [`ferroui-themes-material`](/docs/0.5.0/api/ferroui-themes-material/) · v0.5.0

```rust
struct MaterialSpringSpec
```

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

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Themes.Material/motion.rs#L173)

## Members

- [`new`](#function-new)
- [`damping_ratio`](#function-damping_ratio)
- [`stiffness`](#function-stiffness)
- [`sample`](#function-sample)
- [`settling_duration`](#function-settling_duration)
- [`settling_duration_from`](#function-settling_duration_from)

<a id="function-new"></a>

### new

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Themes.Material/motion.rs#L181)

<a id="function-damping_ratio"></a>

### damping_ratio

```rust
const fn damping_ratio(self: Self) -> f64
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Themes.Material/motion.rs#L196)

<a id="function-stiffness"></a>

### stiffness

```rust
const fn stiffness(self: Self) -> f64
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Themes.Material/motion.rs#L200)

<a id="function-sample"></a>

### sample

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Themes.Material/motion.rs#L211)

<a id="function-settling_duration"></a>

### settling_duration

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Themes.Material/motion.rs#L311)

<a id="function-settling_duration_from"></a>

### settling_duration_from

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Themes.Material/motion.rs#L355)

## 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`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-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](/docs/0.5.0/api/).
