|
psychic-ui 0.0.0
|
#include <Timing.hpp>
Public Member Functions | |
| float | dampingRatio () const |
| Approach | approach (float x0, float v0, float t, float tolerance) const |
| constexpr bool | operator== (const Spring &) const =default |
Public Attributes | |
| float | stiffness {170.0f} |
| float | damping {26.0f} |
| float | mass {1.0f} |
Static Public Attributes | |
| static constexpr std::chrono::nanoseconds | maxTime = std::chrono::seconds(10) |
| static const Spring | Gentle {.stiffness = 170.0f, .damping = 26.0f, .mass = 1.0f} |
| static const Spring | Snappy {.stiffness = 500.0f, .damping = 30.0f, .mass = 1.0f} |
| static const Spring | Bouncy {.stiffness = 400.0f, .damping = 14.0f, .mass = 1.0f} |
A damped spring pulling a value to its target: no duration, it settles when it gets there. Interrupted, it keeps its speed, so a value that reverses half-way turns smoothly. Below a damping of 2√(stiffness × mass) it overshoots and oscillates; at or above it, it doesn't.
Spring{.stiffness = 500, .damping = 30}
|
nodiscard |
Where it is t seconds after it had an offset of x0 and a velocity of v0 (the closed form, so the frame rate doesn't change the motion): settled once the offset is within tolerance and the velocity within tolerance × max(ω, 1), or after maxTime
|
nodiscard |
Its damping ratio: below 1 it overshoots
|
staticconstexpr |
A spring that went on this long is settled