% genRandClusters2D
%
% k       - broj klastera
% nmax    - maksimalan broj tocaka u jednom klasteru
% dispmax - maksimalna disperzija tocaka unutar klastera
%
function A=genRandClusters2D(nc, nmax, dispmax, type)
  if nargin < 4
    type = 'U';
  end
  
  if type == 'R';
    C=rand(nc,2);
  else
    gs = ceil(sqrt(nc));
    sqT = 1/gs;
    xc=sqT/2; yc = sqT/2; k=1;
    while k<=nc
      C(k, 1) = xc;
      C(k, 2) = yc;
      xc = xc+sqT;
      if xc>1
        xc=sqT/2;
        yc = yc+sqT;
      end
      k=k+1;
    end
  end


  k=1;
  a0=randn(ceil(nmax*rand),2);
  a0(:,1)=a0(:,1)*dispmax+C(k,1);
  a0(:,2)=a0(:,2)*dispmax+C(k,2);
  A=a0;
  
  for k=2:nc
    a0=randn(ceil(nmax*rand),2);
    a0(:,1)=a0(:,1)*dispmax+C(k,1);
    a0(:,2)=a0(:,2)*dispmax+C(k,2);
       
    A=[A; a0];
  end

  A=normalizeMatrix(A);

