PointToPointConstraint constructor

PointToPointConstraint(
  1. Body bodyA,
  2. Body bodyB, [
  3. Vec3? pivotA,
  4. Vec3? pivotB,
  5. double maxForce = 1e6,
])

pivotA The point relative to the center of mass of bodyA which bodyA is constrained to. bodyB Body that will be constrained in a similar way to the same point as bodyA. We will therefore get a link between bodyA and bodyB. If not specified, bodyA will be constrained to a static point. pivotB The point relative to the center of mass of bodyB which bodyB is constrained to. maxForce The maximum force that should be applied to constrain the bodies.

Implementation

PointToPointConstraint(
  Body bodyA,
  Body bodyB,
  [
    Vec3? pivotA,
    Vec3? pivotB,
    double maxForce = 1e6
  ]
):super(bodyA, bodyB) {
  this.pivotA = pivotA?.clone() ?? Vec3();
  this.pivotB = pivotB?.clone() ?? Vec3();
  equationX = ContactEquation(bodyA, bodyB);
  final x = equationX;
  equationY = ContactEquation(bodyA, bodyB);
  final y = equationY;
  equationZ = ContactEquation(bodyA, bodyB);
  final z = equationZ;

  // Equations to be fed to the solver
  equations.addAll([x,y,z]);

  // Make the equations bidirectional
  x.minForce = -maxForce;
  y.minForce = -maxForce;
  z.minForce = -maxForce;
  x.maxForce = maxForce;
  y.maxForce = maxForce;
  z.maxForce = maxForce;

  x.ni.set(1, 0, 0);
  y.ni.set(0, 1, 0);
  z.ni.set(0, 0, 1);
}