title: generate 3-d random points with minimum distance between each of them?
body: <p>there.
  I am going to generate 10^6 random points in matlab with this particular characters.
  the points should be inside a sphere with radious 25, the are 3-D so we have x, y, z or r, theta, phi.
  there is a minimum distance between each points.
  first, i decided to generate points and then check the distances, then omit points with do not have these condition. but, it may omit many of points.
  another way is to use RSA (Random Sequential Addition), it means generate points one by one with this minimum distance between them. for example generate first point, then generate second randomly out of the minimum distance from point 1. and go on till achieving 10^6 points.
  but it takes lots of time and i can not reach 10^6 points, since the speed of searching appropriate position for new points will take long time.</p>
  
  <p>Right now I am using this program:</p>
  
  <pre><code>Nmax=10000; 
  R=25; 
  P=rand(1,3); 
  k=1; 
  while k&lt;Nmax 
  theta=2*pi*rand(1); 
  phi=pi*rand(1); 
  r = R*sqrt(rand(1)); 
  % convert to cartesian 
  x=r.*sin(theta).*cos(phi); 
  y=r.*sin(theta).*sin(phi); 
  z=r.*cos(theta); 
  P1=[x y z]; 
  r=sqrt((x-0)^2+(y-0)^2+(z-0)^2); 
  D = pdist2(P1,P,'euclidean'); 
  % euclidean distance 
  
      if D&gt;0.146*r^(2/3) 
          P=[P;P1]; 
          k=k+1;
      end 
      i=i+1; 
  end 
  x=P(:,1);y=P(:,2);z=P(:,3); plot3(x,y,z,'.');
  </code></pre>
  
  <p>How can I efficiently generate points by these condition?
  thank you.</p>