# SpringSolver

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/utilities/spring_solver/struct-springsolver/

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

```rust
struct SpringSolver
```

Solves the motion of a damped spring: maps a time to the position of a
spring that is released at `0` and settles at `1`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/spring_solver.rs#L33)

## Members

- [`from_period`](#function-from_period)
- [`new`](#function-new)
- [`from_natural_frequency`](#function-from_natural_frequency)
- [`solve`](#function-solve)

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

### from_period

```rust
fn from_period(period_seconds: f64, zeta: f64, initial_velocity: f64) -> Self
```

Creates a solver from the period of the undamped oscillation in
seconds, the damping ratio and the initial velocity.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/spring_solver.rs#L44)

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

### new

```rust
fn new(m: f64, k: f64, c: f64, initial_velocity: f64) -> Self
```

Creates a solver from the mass `m`, the stiffness `k`, the damping
coefficient `c` and the initial velocity.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/spring_solver.rs#L54)

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

### from_natural_frequency

```rust
fn from_natural_frequency(wn: f64, zeta: f64, initial_velocity: f64) -> Self
```

Creates a solver from the natural frequency, the damping ratio and
the initial velocity.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/spring_solver.rs#L68)

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

### solve

```rust
fn solve(self: &Self, t: f64) -> f64
```

The position of the spring at time `t`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/utilities/spring_solver.rs#L81)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`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/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `Copy`
- `Debug`
- `Default`
- `StructuralPartialEq`
- `PartialEq`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
