synfig/synfig — pull request #105 by genete (2014-02-14 13:37:53+00:00)
Title: Dynamics

## Implementation of ValueNode_Dynamic

This is the implementation of a new Convert type that allows to link two vectors with a dynamic link. The value node (vector type) that is converted to Dynamic will be *linked* to another vector value using a linear/rotational spring system with damping and friction.

Once you convert the Value to Dynamic it offers the following *subparameters*:

* **Tip Static** (Vector) This is the equilibrium position of the system without external forces relative to the Origin. See *Origin*. Since it is a vector its length is used for the linear spring equilibrium length and its angle form the x axis is used for the torsion spring equilibrium angle. The initial value of this subparameter is the current value of the Value that is being converted to Dynamic.
* **Origin** (Vector) This is the basement of the dynamic system. Defaults to (0.0, 0.0). If the user changes this value the final equilibrium calculated position of the value is modified too. Accelerations of the Origin are used to move the Tip due to the fictitious forces needed to apply under non inertial reference systems.
* **Force** (Vector) External force applied on the Tip of the dynamic system. Defaults to (0.0, 0.0).
* **Torque** (Real) External momentum applied tot he dynamic system at the Origin. Defaults to 0.0.
* **Damping** (Real) Damper coefficient of the linear link. Defaults to 0.4
* **Friction** (Real) Friction coefficient of the rotational link. Defaults to 0.4
* **Spring** (Real) Spring coefficient of the linear link. Defaults to 30.0
* **Torsion** (Real) Torsion coefficient of the rotational link. Defaults to 30.0
* **Mass** (Real) Mass of the dynamic system. Defaults to 0.3
* **Inertia** (Real) Moment of inertia of the dynamic system. Defaults to 0.3

### Comments

* The movement of the Origin produces two effects. It drags the resulting vector the same amount of the Origin along the time (that is the resulting vector is the sum of the Origin(t) + dynamic tip(t)) and its acceleration produces an inertial force contrary to the acceleration direction and magnitude.

* The Torque only affects the angle of the resulting vector respect to the Origin. This means that the mass center of gravity is located at the origin (where the torque is applied) and so there is not centrifugal effects.

* Since the Origin only can be translated, there is not Coriolis forces.

* The Force is applied on the tip position so it would produce effects on the angle and on the length of the tip. Force (F) is decomposed into two vectors one aligned with the Tip vector (Fr) and other perpendicular (Fa). The one aligned (Fr) is used on the linear damper spring equations. The one perpendicular (Fa) is used as additional torque by this expression Fr*R (where R is the size of the Tip vector)

* If Mass (Inertia) is animated and reaches near to zero, then the movement for linear (rotational) link is disabled.

* If Mass (inertia) is constant and equal to zero, then the movement for linear (rotational) link is disabled. It is useful when user wants to create a rigid link on linear (rotational) link.

* Except mass and inertia = 0.0, user is responsible of the meaning of the values of the parameters (i.e. negative mass, or negative friction or spring constant)

### Further development

* Implement reverse manipulation. The Tip Static subparameter should be the one modified when the user tweaks the Dynamic value node handle. This way the user can alter the equilibrium position of the spring (which is other type of animation of this model)

* Add one more subparameter to don't allow Origin to drag the result. Origin would only be used as an input of the movement of the basement but not to calculate the final position of the tip. This is useful when the vector that represent the tip is not a free vector but it is already a vector that depends on other. I. e. Bones.

* Study how to implement this on a chain of bones taking in consideration the reactive internal forces.