function answer = optimize_group_distance(M)

% find all iid
% sort iid's from smallest to largest
% find differences BETWEEN all iid's
% 

iidlist = [];

for i = 1:size(M,1)
   for j = 1:size(M,1)
      iidlist = [iidlist;dist3d(M(i,2), M(i,3), M(i,4), M(j,2), M(j,3), M(j,4))];
	
   end
end
currentbig = 0;
foundone = 0;
p = sort(iidlist);

groupbreak = 0;
for i = 1:(size(p,1)-1)
   diff = (p(i+1)-p(i));
   if (diff > p(i))
      if diff > currentbig
         currentbig =diff;
      end      
   end   
end


answer = currentbig;
