        A[0][1] += w * (yi - y);
            A[1][0] += w * (yi - y);
            A[1][1] += w * Math.pow(yi - y, 2);
            B[0] += w * pixel_in(xj, yi);
            B[1] += w * (yi - y) * pixel_in(xj, yi);
        }
    }
    var px = solved_linear2_or_zero(A, B);
    return px;
}

function dxy(x, y) {
    var dx = dx_from_linear(x, y)[1];
    var dy = dy_from_linear(x, y)[1];
    var l = len(dx, dy);
    if(l < 1e-5)
        return [0.0, 0.0];
    return [dx / l, dy / l];
}

function len_dxy(x, y) {