function [R] = randomGroups2d(n,m,bigRadius,groupRadius)
% randomGroups(n) -- produces n random groups of m points each
% randomly scattered in the 2d plane
% defining the matrix - building the first (index) column
M = [transpose(1:n*m)]

% A, S are arbitrary.  k is used throughout as a counter only.
A = groupRadius;
S= bigRadius;

% centers randomized
centerx = (rand(n,1)*S-S/2)
centery = (rand(n,1)*S-S/2)
k= 0 ;
for j=1:n;
   for i=1:m;
      k=k+1;
      Column2(k) = centerx(j);
   end
end 
T = transpose(Column2);
M = [M T];
k=0;
for j=1:n;
   for i=1:m;
      k=k+1;
      Column3(k) = centery(j);
   end
end   
T = transpose(Column3);
M = [M T];
% random points around that center
theta = rand(n*m,1)*360;
radius = rand(n*m,1)*A;
k = 0;
% modifier is an array that modifies the x and y values
for i = 1:n*m;
   k = k+1;
   xmodifier(k)=(radius(k)*cos(theta(k)));
end
xmodifier = transpose(xmodifier);
k = 0 ;
for i = 1:n*m;
   k = k+1;
   ymodifier(k)=(radius(k)*sin(theta(k)));
end
ymodifier = transpose(ymodifier);
goose = zeros(n*m, 1);
modifier = [goose xmodifier];
modifier = [modifier ymodifier];

finalArray = (M + modifier);
R = finalArray





