/** * Minimal constructor. * * <p>Creates a fixed distance {@link Joint} where the joined {@link Body}s do not participate in * collision detection and resolution. * * @param body1 the first {@link Body} * @param body2 the second {@link Body} * @param anchor1 in world coordinates * @param anchor2 in world coordinates * @throws NullPointerException if body1, body2, anchor1, or anchor2 is null * @throws IllegalArgumentException if body1 == body2 */ public DistanceJoint(Body body1, Body body2, Vector2 anchor1, Vector2 anchor2) { super(body1, body2, false); // verify the bodies are not the same instance if (body1 == body2) throw new IllegalArgumentException(Messages.getString("dynamics.joint.sameBody")); // verify the anchor points are not null if (anchor1 == null) throw new NullPointerException(Messages.getString("dynamics.joint.nullAnchor1")); if (anchor2 == null) throw new NullPointerException(Messages.getString("dynamics.joint.nullAnchor2")); // get the local anchor points this.localAnchor1 = body1.getLocalPoint(anchor1); this.localAnchor2 = body2.getLocalPoint(anchor2); // compute the initial distance this.distance = anchor1.distance(anchor2); }