I'm replying to this thread only to provide a little insight into the discussion that came up on the front page after googling the problem:
Wolfram alpha presents a very nice method for generating points on the unit sphere:
http://mathworld.wolfram.com/SpherePointPicking.htmlNow, in order to generate points
within the sphere, one cannot simply choose a random radius, as that will bunch the points towards the center. It seems that a few people here have come up with a method for generating a hacked version that unclumps them from the center. Arguably, computer graphics is one giant hack, so this might be acceptable to most for finding a "good enough" solution.
Mathematically, if you have a point
x on an
n-dimensional sphere of radius
R and a value
u which is uniformly chosen over the interval [0,
R], then a uniformly random point within the sphere would simply be:
(
u ^ (1/
n)) *
xWhat this means is that in order to find a truly uniformly distributed point within a sphere of radius R one method is to first find a point
on the sphere and then scale it by the cube root of a value chosen from the interval [0, R].
The ramifications of this are that not many computers can do a cube root in a reasonably fast manner when compared to the "close enough" solutions presented in this thread.
I hope I didn't break any forum rules by digging up this thread from the grave, I was hoping to shed some light on whatever googler may come across it as I did.