% Schematic36.m %
clc; clf; clear;
xl=0.0; xr=1.0; n=128; x=linspace(xl,xr,n);
[xx,yy]=meshgrid(x,x); S(1:n,1:n)=0; h=1/128; gam=2*h;
for j=1:n
    for i=1:n
        x = (i-0.5)*h;
        y = (j-0.5)*h;
        theta=atan2(x-0.5,y-0.5);
        S(i,j) = -tanh((sqrt((x-0.5)^2+(y-0.5)^2) ...
            -(0.3*(0.9+0.1*cos(theta*theta)*sin(theta))...
            +0.00*cos(7*theta)))/(sqrt(2.0)*gam));
    end
end
[CC,h]=contour(xx,yy,S',[0 0]);
m2=size(CC,2); xc = CC(1,2:m2); yc = CC(2,2:m2);
plot3(xc,yc,yc*0,'k-','linewidth',1.5)
hold on
plot([0 1],[1 1],'k-','linewidth',1.0)
plot([0 1],[0 0],'k-','linewidth',1.0)
plot([0 0],[0 1],'k-','linewidth',1.0)
plot([1 1],[0 1],'k-','linewidth',1.0)
plot3([0 1],[1 1],[0.5 0.5],'k-','linewidth',1.0)
plot3([0 1],[0 0],[0.5 0.5],'k-','linewidth',1.0)
plot3([0 0],[0 1],[0.5 0.5],'k-','linewidth',1.0)
plot3([1 1],[0 1],[0.5 0.5],'k-','linewidth',1.0)
plot3([0 1],[1 1],[-0.5 -0.5],'k-','linewidth',1.0)
plot3([0 1],[0 0],[-0.5 -0.5],'k-','linewidth',1.0)
plot3([0 0],[0 1],[-0.5 -0.5],'k-','linewidth',1.0)
plot3([1 1],[0 1],[-0.5 -0.5],'k-','linewidth',1.0)
patch(xc,yc,yc*0,[0.8627 0.8627 0.8627])

clear; xl=0.0; xr=1.0; n=128; x=linspace(xl,xr,n);
[xx,yy]=meshgrid(x,x); S(1:n,1:n)=0; h=1/128; gam=2*h; hold on
for j=1:n
    for i=1:n
        x = (i-0.5)*h;
        y = (j-0.5)*h;
        theta=atan2(x-0.5,y-0.5);
        S(i,j) = -tanh((sqrt((x-0.5)^2+(y-0.5)^2) ...
            -(0.3*(0.9+0.3*cos(theta*theta)*sin(theta))...
            +0.00*cos(7*theta)))/(sqrt(2.0)*gam));
    end
end
[CC,h]=contour(xx,yy,S',[0 0]); set(h,'edgecolor','none');
m2=size(CC,2); xc = CC(1,2:m2); yc = CC(2,2:m2);
plot3(xc,yc,yc*0+0.5,'k-','linewidth',1.5)
patch(xc,yc,yc*0+0.5,[0.8627 0.8627 0.8627])

clear; xl=0.0; xr=1.0; n=128; x=linspace(xl,xr,n);
[xx,yy]=meshgrid(x,x); S(1:n,1:n)=0; h=1/128; gam=2*h; hold on
for j=1:n
    for i=1:n
        x = (i-0.5)*h;
        y = (j-0.5)*h;
        theta=atan2(x-0.5,y-0.5);
        S(i,j) = -tanh((sqrt((x-0.5)^2+(y-0.5)^2) ...
            -(0.3*(0.7+0.1*cos(theta*theta)*sin(theta))...
            +0.00*cos(8*theta)))/(sqrt(2.0)*gam));
    end
end
[CC,h]=contour(xx,yy,S',[0 0]); set(h,'edgecolor','none');
m2=size(CC,2); xc = CC(1,2:m2); yc = CC(2,2:m2);
plot3(xc,yc,yc*0-0.5,'k-','linewidth',1.5)
patch(xc,yc,yc*0-0.5,[0.8627 0.8627 0.8627])
axis image; axis off; view(29,20)

h = text(1,1,'$S_n$');
set(h,'interpreter','latex','Position',[0.78 0.3 0.5],...
'fontsize',20);
h = text(1,1,'$S_i$');
set(h,'interpreter','latex','Position',[0.78 0.3 -0.015],...
'fontsize',20);
h = text(1,1,'$S_1$');
set(h,'interpreter','latex','Position',[0.78 0.3 -0.5],...
'fontsize',20);
h = text(1,1,'$\vdots$');
set(h,'interpreter','latex','Position',[0.6 0.3 0.3],...
'fontsize',20);
h = text(1,1,'$\vdots$');
set(h,'interpreter','latex','Position',[0.6 0.3 -0.2],...
'fontsize',20);
set(gcf,'paperpositionmode','auto')