HingeConstraint constructor

HingeConstraint(
  1. Body bodyA,
  2. Body bodyB, {
  3. Vec3? pivotA,
  4. Vec3? pivotB,
  5. Vec3? axisA,
  6. Vec3? axisB,
  7. bool? collideConnected,
  8. double maxForce = 1e6,
})

Implementation

HingeConstraint(
  Body bodyA,
  Body bodyB,
  {
    Vec3? pivotA,
    Vec3? pivotB,
    Vec3? axisA,
    Vec3? axisB,
    bool? collideConnected,
    double maxForce = 1e6
  }
):super(bodyA, bodyB, pivotA, pivotB, maxForce) {
  this.axisA = axisA ?? Vec3(1, 0, 0);
  this.axisA.normalize();

  this.axisB = axisB ?? Vec3(1, 0, 0);
  this.axisB.normalize();

  this.collideConnected = collideConnected ?? true;
  rotationalEquation1 = RotationalEquation(bodyA, bodyB, axisA: this.axisA,axisB: this.axisB, maxForce: maxForce);
  final rotational1 = rotationalEquation1;
  rotationalEquation2 = RotationalEquation(bodyA, bodyB, axisA: this.axisA,axisB: this.axisB, maxForce: maxForce);
  final rotational2 = rotationalEquation2;
  motorEquation = RotationalMotorEquation(bodyA, bodyB, maxForce);
  final motor = motorEquation;
  motor.enabled = false; // Not enabled by default

  // Equations to be fed to the solver
  equations.addAll([rotational1,rotational2,motor]);
}