Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Properties | List of all members
SpringAnimation Class Reference

#include <spring_animation.h>

Inheritance diagram for SpringAnimation:

Instance Methods

(instancetype) - initWithStiffness:damping:mass:initialVelocity:fromValue:toValue:
 
(double) - curveFunction:
 

Properties

double stiffness
 
double damping
 
double mass
 
double initialVelocity
 
double fromValue
 
double toValue
 
double zeta [implementation]
 
double omega0 [implementation]
 
double omega1 [implementation]
 
double v0 [implementation]
 

Detailed Description

Definition at line 23 of file spring_animation.h.

Method Documentation

◆ curveFunction:

- (double) curveFunction: (double)  t

Definition at line 20 of file spring_animation.mm.

50 :(double)t {
51 const double x0 = _toValue - _fromValue;
52
53 double y;
54 if (_zeta < 1) {
55 // Under damped.
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 // Critically damped.
61 const double envelope = exp(-_omega0 * t);
62 y = _toValue - envelope * (x0 + (_v0 + _omega0 * x0) * t);
63 }
64
65 return y;
66}
double y

◆ 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.

27 :(double)stiffness
28 damping:(double)damping
29 mass:(double)mass
31 fromValue:(double)fromValue
32 toValue:(double)toValue {
33 self = [super init];
34 if (self) {
35 _stiffness = stiffness;
36 _damping = damping;
37 _mass = mass;
38 _initialVelocity = initialVelocity;
39 _fromValue = fromValue;
40 _toValue = toValue;
41
42 _zeta = _damping / (2 * sqrt(_stiffness * _mass)); // Damping ratio.
43 _omega0 = sqrt(_stiffness / _mass); // Undamped angular frequency of the oscillator.
44 _omega1 = _omega0 * sqrt(1.0 - _zeta * _zeta); // Exponential decay.
45 _v0 = -_initialVelocity;
46 }
47 return self;
48}
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition SkVx.h:706
init(device_serial, adb_binary)
Definition _adb_path.py:12

Property Documentation

◆ damping

- (double) damping
readnonatomicassign

Definition at line 35 of file spring_animation.h.

◆ fromValue

- (double) fromValue
readwritenonatomicassign

Definition at line 38 of file spring_animation.h.

◆ initialVelocity

- (double) initialVelocity
readnonatomicassign

Definition at line 37 of file spring_animation.h.

◆ mass

- (double) mass
readnonatomicassign

Definition at line 36 of file spring_animation.h.

◆ omega0

- (double) omega0
readwritenonatomicassignimplementation

Provided by category SpringAnimation().

Definition at line 18 of file spring_animation.mm.

◆ omega1

- (double) omega1
readwritenonatomicassignimplementation

Provided by category SpringAnimation().

Definition at line 19 of file spring_animation.mm.

◆ stiffness

- (double) stiffness
readnonatomicassign

Definition at line 34 of file spring_animation.h.

◆ toValue

- (double) toValue
readwritenonatomicassign

Definition at line 39 of file spring_animation.h.

◆ v0

- (double) v0
readwritenonatomicassignimplementation

Provided by category SpringAnimation().

Definition at line 20 of file spring_animation.mm.

◆ zeta

- (double) zeta
readwritenonatomicassignimplementation

Provided by category SpringAnimation().

Definition at line 17 of file spring_animation.mm.


The documentation for this class was generated from the following files: