SpringConstraint constructor

SpringConstraint(
  1. Body bodyA,
  2. Body bodyB, {
  3. double stiffness = 1,
  4. double damping = 1,
})

Implementation

SpringConstraint(
  Body bodyA,
  Body bodyB,
  {
    this.stiffness = 1,
    this.damping = 1,
  }
):super(bodyA, bodyB){
  _restLength = bodyA.position.distanceTo(bodyB.position);
  distanceEquation = ContactEquation(bodyA, bodyB);
  final eq = distanceEquation;
  equations.add(eq);

  // Make it bidirectional
  eq.minForce = -stiffness;
  eq.maxForce = stiffness;
}