ForceDistanceConstraint

ForceDistanceConstraint is a Constraint that constrains the distance between two particles. It uses a force-based implementation and can be thought of as a spring between two particles. In general, energy conservation is better at lower stiffness, and it can behave unstable or energetically inconsistent at higher stiffness.

Constructor

new ForceDistanceConstraint(c1, c2, len, stiffness, breakForce, dampening)

Instantiates new ForceDistanceConstraint

Parameters:
NameTypeDefaultDescription
c1Particle

particle 1

c2Particle

particle 2

lenNumber

constrained length

stiffnessNumber

the "spring constant", higher values are more stiff

breakForceNumber

force at which the constraint breaks

dampeningNumber0

damping force on constraint, must be greater than 0

Extends

Methods

applyCorrection(timeStep)

Applies positional correction on particle.

Parameters:
NameTypeDescription
timeStepNumber

particles() → {Array.<Particle>}

Calculates the list of particles that is involved with the constraint

Returns:
Type: 
Array.<Particle>

update(timeStep)

Updates the constraint.

Parameters:
NameTypeDescription
timeStepNumber

vertices() → {Array.<Vector2D>}

Calculates the list of vertices that will be used in the rendering process

Returns:
Type: 
Array.<Vector2D>