         B[0] += w * pixel_in(xj, yi);
            B[1] += w * (xj - x) * pixel_in(xj, yi);
        }
    }
    var px = solved_linear2_or_zero(A, B);
    return px;
}

function dy_from_linear(x, y) {
    var A = [[0.0, 0.0], [0.0, 0.0]];
    var B = [0.0, 0.0];
    for(var yi = y - nd * grid_size; yi <= y + nd * grid_size; yi += grid_size) {
        for(var xj = x - nd * grid_size; xj <= x + nd * grid_size; xj += grid_size) {
            var w = weight_of_point(x, y, xj, yi);
            A[0][0] += w;
    