function [final] = squareGroups2d (n, g)

% n is number of individuals in a group.  Must be a square number.
% g is number of groups.

[centers] = evenGroupCenters2d(g);
[centers] = addIndex2d(centers);
[final] = [];

for i = 1:length(centers)
   [temp] = evenPtsSqr2d(n);
   [temp] = addIndex2d(temp);
   for j = 1:length(temp)
      temp(j, 2) = temp(j,2) + centers(i, 2);
      temp(j, 3) = temp(j,3) + centers(i, 3);
   end
   [final] = [final;temp];
end


