LockConstraint constructor
Implementation
LockConstraint(
Body bodyA,
Body bodyB,
{
double maxForce = 1e6
}
):super(bodyA, bodyB, null,null, maxForce) {
final halfWay = Vec3();
bodyA.position.vadd(bodyB.position, halfWay);
halfWay.scale(0.5, halfWay);
bodyB.pointToLocalFrame(halfWay, pivotB);
bodyA.pointToLocalFrame(halfWay, pivotA);
// The point-to-point constraint will keep a point shared between the bodies
// Store initial rotation of the bodies as unit vectors in the local body spaces
xA = bodyA.vectorToLocalFrame(Vec3.unitX);
xB = bodyB.vectorToLocalFrame(Vec3.unitX);
yA = bodyA.vectorToLocalFrame(Vec3.unitY);
yB = bodyB.vectorToLocalFrame(Vec3.unitY);
zA = bodyA.vectorToLocalFrame(Vec3.unitZ);
zB = bodyB.vectorToLocalFrame(Vec3.unitZ);
// ...and the following rotational equations will keep all rotational DOF's in place
rotationalEquation1 = RotationalEquation(
bodyA,
bodyB,
maxForce: maxForce,
);
final r1 = rotationalEquation1;
rotationalEquation2 = RotationalEquation(
bodyA,
bodyB,
maxForce: maxForce,
);
final r2 = rotationalEquation2;
rotationalEquation3 = RotationalEquation(
bodyA,
bodyB,
maxForce: maxForce,
);
final r3 = rotationalEquation3;
equations.addAll([r1,r2,r3]);
}