% Schematic35.m %
%%%%% HexaSchematic.m %%%%%
clear all; close all; clc; clf; 
nx = 600; ny = nx; x = linspace(0,2,nx);
y = linspace(0.5,3.9642,nx); 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:6 
                if((xx-a)^2 + (yy-b)^2 <= r^2)
                    c(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)
                    c(i,j) = 1.0;
                end
            end
        end
    end
end
[xx,yy] = meshgrid(x,y);
figure;
hold on 
contourf(xx,yy,c',[0 0 0]+0.5)
view(0,90)
colormap gray
axis image
line([0 2 2 0 0],[0.5 0.5 2*1.7321+0.5 2*1.7321+0.5 0.5],'color','k')
for i = 0.3464:0.3464:2*1.7321-0.3464
    line([0 2],[0.5+i 0.5+i])
end
for i = 0.25:0.25:2-0.1
    line([i i],[0 2*1.7321]+0.5)
end
line([0 2],[0.5 0.5]-0.1,'color','k','linewidth',1)
line([2 2]+0.1,[0 2*1.7321]+0.5,'color','k','linewidth',1)
plot(0.1, 0.4,'k<','markersize',10,'markerfacecolor','k')
plot(1.9, 0.4,'k>','markersize',10,'markerfacecolor','k')
plot(2.1, 0.4+2*1.7321,'k^','markersize',10,'markerfacecolor','k')
plot(2.1, 0.6,'kv','markersize',10,'markerfacecolor','k')

text('Interpreter','latex', 'String','$$a$$', 'Position',...
[0.9576 0.3 25.48],'FontSize',20)
text('Interpreter','latex', 'String','$$\sqrt{3}a$$','Position',...
[2.158 2.244 25.48],'FontSize',20)
axis off
plot(0-0.5,0.5-0.4,'w.')
plot(2+0.5,2*1.7321+0.5+0.3,'w.')
axis([0-0.5 2+0.5 0.5-0.4 2*1.7321+0.5+0.3])
set(gcf,'paperpositionmode','auto')