function priklad2Elektrody()

U = 1;
quadOrder = 5;

% diskretizace
h = 0.25/2^3;
Rohy = [[-0.25;-1] [0.25;-1] [0.25;1] [-0.25;1]];
[P,E] = discretizePolygon(Rohy,h);
PMinus = P; PMinus(1,:) = PMinus(1,:) - 0.5;
n = size(PMinus,2);
PPlus = P; PPlus(1,:) = PPlus(1,:) + 0.5;
P = [PMinus,PPlus];
P = 0.1*P;
E = [E,n+E];

% sestaveni matice
V = kolokacniMatice1Vrstvy2dLaplace(P,E,quadOrder);

% sestaveni prave strany
e = ones(n,1);
b = [-U*e;U*e];

% reseni
q = V\b;

% vykresleni pomocneho naboje q na hranici
drawSolution_L0seg(P,E,q)
view(3)

% vykresleni pole u(x) = int_Gamma G(x,y)*q(y) dl(y)
x = -0.3:0.01:0.3;
y = x;
[X,Y] = meshgrid(x,y);
epsil = 1e-4;
xmin = min(abs(P(1,:)))-epsil;
xmax = max(P(1,:))+epsil;
ymin = min(P(2,:))-epsil;
ymax = max(P(2,:))+epsil;
Oblast = X; Oblast(:) = 0;
Oblast(X>-xmax & X<-xmin & Y>ymin & Y<ymax) = -1; % uvnitr leve elektrody
Oblast(X>xmin & X<xmax & Y>ymin & Y<ymax) = 1; % uvnitr prave elektrody
idxOut = find(Oblast==0);
volP = [X(idxOut)';Y(idxOut)'];
V = potencial1Vrstvy2dLaplace(P,E,q,volP,quadOrder);
Potencial = X;
Potencial(Oblast==-1) = -U;
Potencial(Oblast==1) = U;
Potencial(idxOut) = V;
figure
mesh(X,Y,Potencial)

% vykresleni pole E = -grad u(x) = int_Gamma grad_x(G(x,y))*q(y) dl(y)
gradV = gradPotencial1Vrstvy2dLaplace(P,E,q,volP,quadOrder);
GradPotencial1 = X;
GradPotencial1(Oblast==-1) = 0;
GradPotencial1(Oblast==1) = 0;
GradPotencial1(idxOut) = gradV(1,:);
GradPotencial2 = X;
GradPotencial2(Oblast==-1) = 0;
GradPotencial2(Oblast==1) = 0;
GradPotencial2(idxOut) = gradV(2,:);
figure
quiver(X,Y,GradPotencial1,GradPotencial2)
