% Statistical Mechanics of Elasticity
% Felix Hildebrand - felixhi@ethz.ch

% This function plots a 2D 2-lattice with lattice vectors a1, a2 and shift
% p. n specifies the figure number

function plotLattice(a1,a2,p,n)

% number of rows/columns
m = 5;

% initialize positions
xA = zeros(m^2,2);
xB = zeros(m^2,2);

% calculate lattice sites from a1, a2 and p
k=1;
for i=0:m-1
    for j=0:m-1
        xA(k,:)=(i*a1+j*a2)';
        xB(k,:)=(p+i*a1+j*a2)';
        k=k+1;
    end
end

% plot atoms
figure(n)
hold on;
axis equal;
axis off;
plot(xA(:,1),xA(:,2),'ok','MarkerFaceColor','w','MarkerSize',6);
plot(xB(:,1),xB(:,2),'ok','MarkerFaceColor','k','MarkerSize',6);
legend('A','B')
hold off;

return