Damped harmonic oscillator. More...
#include <phosphor-animation/include/PhosphorAnimation/Spring.h>
Public Member Functions | |
| Spring ()=default | |
| Spring (qreal omega, qreal zeta) | |
| Spring (const Spring &)=default | |
| Spring & | operator= (const Spring &)=default |
| Spring (Spring &&)=default | |
| Spring & | operator= (Spring &&)=default |
| QString | typeId () const override |
| Stable identifier for this curve subclass (e.g. "bezier", "spring"). | |
| qreal | evaluate (qreal t) const override |
| Evaluate at normalized time t in [0,1]. May overshoot by design. | |
| void | step (qreal dt, CurveState &state, qreal target) const override |
Advance state by dt real seconds toward target. | |
| bool | isStateful () const override |
| True if this curve requires persistent CurveState across frames. | |
| qreal | settleTime () const override |
| Approximate settle time in seconds. | |
| QString | toString () const override |
| Serialize to "typeId:params" or bare "x1,y1,x2,y2" for cubic-bezier. | |
| std::unique_ptr< Curve > | clone () const override |
| Deep copy with identical parameters. | |
| bool | overshoots () const override |
| True for underdamped (zeta < 1). Critical/overdamped never overshoot. | |
| bool | equals (const Curve &other) const override |
| Same typeId + same parameters. | |
| bool | operator== (const Spring &other) const |
| bool | operator!= (const Spring &other) const |
Public Member Functions inherited from PhosphorAnimation::Curve | |
| virtual | ~Curve ()=default |
Static Public Member Functions | |
| static Spring | fromString (const QString &str) |
| Parse from "spring:omega,zeta" or "omega,zeta". Clamps to valid ranges. | |
| static Spring | snappy () |
| Responsive, slight overshoot. | |
| static Spring | smooth () |
| Critically damped, no overshoot. | |
| static Spring | bouncy () |
| Visible bounce. | |
Public Attributes | |
| qreal | omega = 12.0 |
| Angular natural frequency (rad/s). [0.1, 200]. | |
| qreal | zeta = 0.8 |
| Damping ratio. [0.0, 10.0]. | |
Additional Inherited Members | |
Protected Member Functions inherited from PhosphorAnimation::Curve | |
| Curve ()=default | |
| Curve (const Curve &)=default | |
| Curve & | operator= (const Curve &)=default |
| Curve (Curve &&)=default | |
| Curve & | operator= (Curve &&)=default |
Damped harmonic oscillator.
Params: omega (angular frequency, rad/s, [0.1,200]) and zeta (damping ratio, [0,10]). Matches Framer Motion / SwiftUI conventions. evaluate() = analytical step-response; step() = semi-implicit Euler integration. Wire format: "spring:omega,zeta".
|
default |
| PhosphorAnimation::Spring::Spring | ( | qreal | omega, |
| qreal | zeta | ||
| ) |
|
default |
|
default |
|
static |
Visible bounce.
|
overridevirtual |
Deep copy with identical parameters.
Implements PhosphorAnimation::Curve.
|
overridevirtual |
Same typeId + same parameters.
Default compares toString() (2-decimal rounded); subclasses with precise floats should override.
Reimplemented from PhosphorAnimation::Curve.
|
overridevirtual |
Evaluate at normalized time t in [0,1]. May overshoot by design.
Implements PhosphorAnimation::Curve.
|
static |
Parse from "spring:omega,zeta" or "omega,zeta". Clamps to valid ranges.
|
inlineoverridevirtual |
True if this curve requires persistent CurveState across frames.
Reimplemented from PhosphorAnimation::Curve.
|
inline |
| bool PhosphorAnimation::Spring::operator== | ( | const Spring & | other | ) | const |
|
overridevirtual |
True for underdamped (zeta < 1). Critical/overdamped never overshoot.
Reimplemented from PhosphorAnimation::Curve.
|
overridevirtual |
Approximate settle time in seconds.
Parametric: 1.0 (the [0,1] domain). Spring: analytical 99% settle time. Never infinity.
Reimplemented from PhosphorAnimation::Curve.
|
static |
Critically damped, no overshoot.
|
static |
Responsive, slight overshoot.
|
overridevirtual |
Advance state by dt real seconds toward target.
dt <= 0 is a no-op. Default impl maps to parametric evaluation using state.startValue/time/duration. For retarget with stateless curves: set startValue = value, time = 0 before changing target.
Reimplemented from PhosphorAnimation::Curve.
|
overridevirtual |
Serialize to "typeId:params" or bare "x1,y1,x2,y2" for cubic-bezier.
2-decimal float precision — round-trip is lossy.
Implements PhosphorAnimation::Curve.
|
overridevirtual |
Stable identifier for this curve subclass (e.g. "bezier", "spring").
Implements PhosphorAnimation::Curve.
| qreal PhosphorAnimation::Spring::omega = 12.0 |
Angular natural frequency (rad/s). [0.1, 200].
| qreal PhosphorAnimation::Spring::zeta = 0.8 |
Damping ratio. [0.0, 10.0].