[Demonstration 1]

[Buggy Method]
boolean solveShapeMatchingConstraint(final Vector3[] x0, final Vector3[] x, final float[] invMasses, final int numPoints, final Vector3 restCm, final Matrix3 invRestMat, final float stiffness, final boolean allowStretch, Vector3[] corr, Matrix3 rot) {
    final float eps = 1e-6f;
    for (Vector3 c : corr) {
        c.setZero();
    }
    Vector3 cm = new Vector3();
    float wSum = 0.0f;
    for (int i = 0; i < invMasses.length; i++) {
        float wi = 1.0f / (invMasses[i] + eps);
        cm.add(new Vector3(x[i]).scl(wi));
        wSum += wi;
    }
    if (wSum == 0.0f) {
        return false;
    }
    cm.scl(1 / wSum);
    // A
    Matrix3 mat = new Matrix3(new float[9]);
    for (int i = 0; i < invMasses.length; i++) {
        Vector3 q = new Vector3(x0[i]).sub(restCm);
        Vector3 p = new Vector3(x[i]).sub(cm);
        float w = 1.0f / (invMasses[i] + eps);
        p.scl(w);
        float[] m = mat.val;
        m[Matrix3.M00] += p.x * q.x;
        m[Matrix3.M01] += p.x * q.y;
        m[Matrix3.M02] += p.x * q.z;
        m[Matrix3.M10] += p.y * q.x;
        m[Matrix3.M11] += p.y * q.y;
        m[Matrix3.M12] += p.y * q.z;
        m[Matrix3.M20] += p.z * q.x;
        m[Matrix3.M21] += p.z * q.y;
        m[Matrix3.M22] += p.z * q.z;
    }
    mat.mul(invRestMat);
    // REVIEW
    Matrix3 R, U, D;
    R = mat;
    if (!allowStretch) {
        polarDecomposition2(mat, 1e-6f, R);
    }
    for (int i = 0; i < corr.length; i++) {
        Vector3 goal = new Vector3(x0[i]).sub(restCm).mul(R).add(cm);
        corr[i] = goal.sub(x[i]).scl(stiffness);
    }
    if (rot != null) {
        rot = R;
    }
    return true;
}

[Buggy Hunk]
boolean solveShapeMatchingConstraint(final Vector3[] x0, final Vector3[] x, final float[] invMasses, final int numPoints,

[Patch]
public static boolean solveShapeMatchingConstraint(final Vector3[] x0, final Vector3[] x, final float[] invMasses, final int numPoints,

[Demonstration 2]

[Buggy Method]
public Loc getLocAt(Point point) {
    //The input point is raw x,y in the UI, so we need to tranlsate to where it would be in our drawing space.
    int x = (point.x - offset.x - origin.y) / pixsToGrid;
    int y = (point.y - offset.y - origin.y) / pixsToGrid;
    if (Loc.isValid(x, y))
        return Loc.make(x, y);
    return null;
}

[Buggy Hunk]
int x = (point.x - offset.x - origin.y)/pixsToGrid;

[Patch]
int x = (point.x - offset.x - origin.x)/pixsToGrid;

[Demonstration 3]

[Buggy Method]
public List<Edge> incomings() {
    return incomings;
}

[Buggy Hunk]
public List<Edge> incomings() {

[Patch]
public Set<Edge> incomings() {