% Schematic34.m %
%%%%% Hexa.m %%%%%
clear all; close all; clc; clf; 
nx = 600; ny = nx; x = linspace(0,7,nx); y = x; r = 0.5;
for i = 1:nx
    for j = 1:ny
        c(i,j) = 0.0;
        xx = x(i); yy = y(j);
        for a = 0:2:6
            for b = 0.5:2*1.7321:7 
                if((xx-a)^2 + (yy-b)^2 <= r^2)
                    c(i,j) = 1.0;
                end
            end
        end
        for a = 1:2:5
            for b = 0.5+1.7321:2*1.7321:7 
                if((xx-a)^2 + (yy-b)^2 <= r^2)
                    c(i,j) = 1.0;
                end
            end
        end
    end
end
[xx1,yy1] = meshgrid(x,y);

nx = 600; ny = nx;  x = linspace(2,4,nx);
y = linspace(0.5,3.9642,nx); r = 0.5;
for i = 1:nx
    for j = 1:ny
        cc(i,j) = 0.0;
        xx = x(i); yy = y(j);
        for a = 0:2:6
            for b = 0.5:2*1.7321:6 
                if((xx-a)^2 + (yy-b)^2 <= r^2)
                    cc(i,j) = 1.0;
                end
            end
        end
        for a = 1:2:6
            for b = 0.5+1.7321:2*1.7321:7 
                if((xx-a)^2 + (yy-b)^2 <= r^2)
                    cc(i,j) = 1.0;
                end
            end
        end
    end
end

figure;
hold on 
contour(xx1,yy1,c',[0 0 0]+0.5,'linestyle',':')
[xx2,yy2] = meshgrid(x,y);
contourf(xx2,yy2,cc',[0 0 0]+0.5,'linewidth',1)
view(0,90)
colormap gray
axis image
line([2 4],[0.5 0.5],'linestyle','--','color','k')
line([1 5],[0.5 0.5]+1.7321,'linestyle','--','color','k')
line([2 4],[0.5 0.5]+2*1.7321,'linestyle','--','color','k')
line([2 4],[0.5 0.5+2*1.7321],'linestyle','--','color','k')
line([4 2],[0.5 0.5+2*1.7321],'linestyle','--','color','k')
line([2 1],[0.5 0.5+1*1.7321],'linestyle','--','color','k')
line([4 5],[0.5 0.5+1*1.7321],'linestyle','--','color','k')
line([1 2],[0.5+1*1.7321 0.5+2*1.7321],'linestyle','--','color','k')
line([5 4],[0.5+1*1.7321 0.5+2*1.7321],'linestyle','--','color','k')
axis off
line([0 2 2 0 0]+2,[0.5 0.5 2*1.7321+0.5 2*1.7321+0.5 0.5],...
'color','k')
axis([0 6 0 6])
set(gcf,'paperpositionmode','auto')
