# TorsionSpringConstraint

A torsion spring applies a torque based on a relative angle and a relative angular velocity. Specifically, torsion springs try to bring two axes from two parts together in a compliance way.

This constraint is ideal for building vehicle suspension.

## Summary

### Properties

The current angle, in degrees, of the limiting cone.

Determines whether the angular motion of attachments' secondary axes is limited.

The restitution coefficient of the cone constraint.

### Methods

### Events

## Properties

### Coils

This property indicates the number of spring coils for visualization. The default value is 8.

### CurrentAngle

The current angle, in degrees, of the TorsionSpringConstraint's limiting cone. The limiting cone is formed at the position of the constraint's Attachment0 around its secondary axis with an angle equal to MaxAngle.

### Damping

This property determines how the angular velocity is dampened by the constraint and is expressed as the torsional damping c_t in the formula: T=-k_t (Δ*Θ) - c_t (Δ⋅Θ). The value defaults to 0.01.

Damping of the torsion spring causes the spring to oppose the relative angular velocity. For instance, if the two axes are rotating toward each other with an angular velocity (Δ⋅Θ < 0) an opposing torque will try to slow down this relative rotation (T>0). If the axes were rotating away from each other (Δ⋅Θ > 0) an opposing torque (T<0) will slow down this angular velocity. In both cases, the damping is resulting in a torque that opposes the motion.

In the example below, developers can change the damping of the torsion spring as follows:

torsionSpring.Damping = 1.0

### LimitsEnabled

This property, when enabled, limits the relative angular motion of the secondary axes of attachments through a cone constraint. The default value is false.

In the example below, you can enable a cone limit on the relative motion of the secondary axes as follows:

torsionSpring.LimitEnabled = true

### MaxAngle

This property determines the maximum angle (in degrees) of the TorsionSpringConstraint's limiting cone. The limiting cone is formed at the position of the constraint's Attachment0 around its secondary axis with an angle equal to MaxAngle. The default value is 45.0 degrees.

In the example below, when LimitEnabled is true for the constraint, the maximum angle between the primary axes of attachments can be limited to 10 degrees for instance as follows:

torsionSpring.MaxAngle = 10

### MaxTorque

This property determines the maximum torque supported by the spring. The value defaults to 1000.0.

If a part isn't moving, consider raising this value (and also check that it is not Anchored or attached to another anchored part).

#### What is torque

Torque is equivalent to a force applied over a distance (T = force * distance). The same way that applying a force translates into pulling/pushing an object, applying a torque results in rotating the object.

#### Setting the MaxTorque

In the example below, you can change the maximum torque provided by the torsion spring as follows:

torsionSpring.MaxTorque = 300

### Radius

When developing in studio, the spring will always be visualized, regardless of the camera distance.

This property indicates the visualization radius of the spring, in studs. The default value is 0.4.

### Restitution

This property how elastic Attachments connected by a TorsionSpringConstraint are when they reach the end of the range specified by MaxAngle when LimitEnabled is true. The value defaults to 0 and can be any floating number within the range [0, 1].

torsionSpring.Restitution = 0

#### What is restitution

Restitution determines the damping effect that the constraint applies when it reaches its limits.

Imagine you release a ball from some distance and it hits the ground. If the restitution of the surface is 1 then the ball will return to its original height (no energy is damped). If the restitution is 0 the ball will stick to the ground (all the energy is lost). Similarly, automobiles rely on damping for shock absorption as do some "slow-close" doors.

All the values between 0 and 1 will simulate something between these to extreme cases.

### Stiffness

This property determines the magnitude of the opposing torque of the spring, in the absence of damping, and is expressed as k_t in the formula: T=-k_t (Δ*Θ) - c_t (Δ⋅Θ). The value defaults to 100.

In the absence of damping, the opposing torque of the spring is proportional to the stiffness parameter. For instance, higher stiffness results in a larger opposing torque, and smaller stiffness results in a smaller opposing torque. The larger the torque value, the faster the axes are pushed together when the relative angle is positive (or away from each other if the relative angle is negative).

In the example below, developers can change the stiffness of the torsion spring as follows:

torsionSpring.Stiffness = 1000