Posted this at math stack exchange as well, but alas no replies! So, I have been trying to find ways of distributing particles of spherical or other shape in 3D space, e.g. rectangular space. Random() and checking for overlaps will only get you up to a certain volume fraction percentage, then it is nearly impossible to find a non-overlapping position. I know there is a way to "drive" particles in empty spaces by some sort of Monte Carlo distribution or using some kind of potential difference? A dirty example in pseudo code or Matlab would be awesome!