Spring

The spring component can be used to model springs with optional damping and plastic deformation. For more details on all properties associated with the spring component and how to use the spring component with scripting, please see the API documentation.

Springs act on dynamic joints, applying a force proportional to the difference between the current position and resting position of the joint. They can only act on prismatic or revolute joints.

Properties

The spring component properties that are accessible through the inspector.

Joint

The joint that the spring force/torque is applied to. This can only be a prismatic or revolute joint.

Stiffness

The stiffness coefficient for the spring. Increasing the stiffness will result in a greater force being applied to bring the joint back to the resting position. It may be necessary to reduce the timestep in order to simulate stiff springs without instability.

Damping

The damping coefficient for the spring. Increasing the damping will cause the amplitude of oscillations to decrease quicker. Increasing the damping beyond the critical damping coefficient value will prevent oscillations.

Rest Offset

The rest offset is used to determine the resting position. The resting position is determined from the sum of the initial position of the joint and the resting offset. Note that a rest offset of zero means that the resting position is equal to the initial position of the joint.

Yield Displacement

The yield displacement is used to control plastic deformation of the spring. Note that a yield displacement of zero will cause the spring to be perfectly elastic. A strictly positive yield displacement will cause the rest offset to change if the extension/compression of the spring exceeds the yield displacement.

Theory

There are two coefficients that affect the behavior of a spring: stiffness and damping. The total force applied by the spring is calculated as the sum of the forces due to stiffness and damping:

$$F=F_s+F_d$$

Stiffness

Stiffness is a measure of how much force is required to extend/compress the spring. A stiffness of zero means that the spring applies no force to bring the joint back to the resting position. A non-zero stiffness with zero damping will cause the joint to oscillate around the resting position. The force due to the stiffness, is given by the following equation, where k is the spring constant and x is the difference between the current position and the resting position:

$$F_{s}=-kx$$

The period of the oscillation for a prismatic/linear spring is given by the following equation, where m is the mass of the body:

$$T=2\pi\sqrt{\frac{m}{k}}$$

The period of oscillation for a revolute/torsional spring is given by the following equation, where I is the moment of inertia of the body:

$$T=2\pi\sqrt{\frac{m}{I}}$$

If the stiffness coefficient is high, the spring may try to oscillate faster than the timestep. This causes the spring to become unstable. The maximum stiffness for stable oscillations can be calculated as follows:

$$k_{max}=\frac{m}{dt^2}$$
$$k_{max}=\frac{I}{dt^2}$$

Using the maximum stiffness will cause the spring to move the joint to its resting position in a single timestep. If your spring is unstable, you may need to either reduce the stiffness or reduce the timestep so as to increase the maximum stable stiffness.

Damping

Damping is a measure of how much energy is dissipated over a period of time. Positive damping values can be used to reduce or prevent oscillations. The force applied due to damping is given by the following equation, where c is the damping coefficient and v is the velocity of the joint:

$$F_{d}=-cv$$

The critical damping coefficient is the minimum coefficient value at which the spring no longer oscillates. The critical damping coefficient can be computed using the following equations:

$$c_{c}=2\sqrt{km}$$
$$c_{c}=2\sqrt{kI}$$

Note that for revolute/torsional springs, the Parallel Axis Theorem must be applied to calculate the moment of inertia if the anchor point of the joint is not aligned with the center of mass of the body along the direction of the axis.

Plastic Deformation

Springs are perfectly elastic by default. This means that regardless of how much they are extended/compressed, the spring will eventually return the joint back to its resting position if no other forces are acting on the body. However, springs also support plastic deformation where sufficient extension/compression will cause the spring to change its resting position. This can be used to model the folding of cardboard boxes, where sufficient deflection of the flaps should cause the flaps to remain folded.