#import <spring_animation.h>
Definition at line 23 of file spring_animation.h.
◆ curveFunction:
- (double) curveFunction: |
|
(double) |
t |
|
Definition at line 20 of file spring_animation.mm.
50 :(double)t {
51 const double x0 = _toValue - _fromValue;
52
54 if (_zeta < 1) {
55
56 const double envelope = exp(-_zeta * _omega0 * t);
57 y = _toValue - envelope * (((_v0 + _zeta * _omega0 * x0) / _omega1) * sin(_omega1 * t) +
58 x0 * cos(_omega1 * t));
59 } else {
60
61 const double envelope = exp(-_omega0 * t);
62 y = _toValue - envelope * (x0 + (_v0 + _omega0 * x0) * t);
63 }
64
66}
◆ initWithStiffness:damping:mass:initialVelocity:fromValue:toValue:
- (instancetype) initWithStiffness: |
|
(double) |
stiffness |
damping: |
|
(double) |
damping |
mass: |
|
(double) |
mass |
initialVelocity: |
|
(double) |
initialVelocity |
fromValue: |
|
(double) |
fromValue |
toValue: |
|
(double) |
toValue |
|
|
| |
Definition at line 20 of file spring_animation.mm.
33 self = [super init];
34 if (self) {
41
42 _zeta = _damping / (2 *
sqrt(_stiffness * _mass));
43 _omega0 =
sqrt(_stiffness / _mass);
44 _omega1 = _omega0 *
sqrt(1.0 - _zeta * _zeta);
45 _v0 = -_initialVelocity;
46 }
47 return self;
48}
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
◆ damping
◆ fromValue
◆ initialVelocity
- (double) initialVelocity |
|
readnonatomicassign |
◆ mass
◆ omega0
|
readwritenonatomicassignimplementation |
◆ omega1
|
readwritenonatomicassignimplementation |
◆ stiffness
◆ toValue
◆ v0
|
readwritenonatomicassignimplementation |
◆ zeta
|
readwritenonatomicassignimplementation |
The documentation for this class was generated from the following files: