function gradVt = gradPotencial1Vrstvy2dLaplace(nodes,edges,t,volPoints,order);

load GaussQuadratureForLineSegments.mat

tau  = points{order};
etau = 1-tau;
w = weights{order};

m = size(edges,2);
n = size(volPoints,2);

gradVt = zeros(2,n);

for i=1:n
    xi1 = volPoints(:,i);

    for j=1:m
        edgej = edges(:,j);
        nodesj = nodes(:,edgej);
        xj1 = nodesj(:,1);
        xj2 = nodesj(:,2);
        tj = xj2-xj1;
        Sj = norm(tj);
        nj = [tj(2);-tj(1)]/Sj;

        a = xi1-xj1;

        AB1 = a(1)-tj(1)*tau;
        AB2 = a(2)-tj(2)*tau;
        norm1 = sqrt(AB1.^2+AB2.^2);
        gradF1 = AB1./norm1.^2;
        gradF2 = AB2./norm1.^2;
        gradVt(1,i) = gradVt(1,i) + t(j) * Sj*w*gradF1';
        gradVt(2,i) = gradVt(2,i) + t(j) * Sj*w*gradF2';
    end
    
end

gradVt = gradVt/(-2*pi);
