3 ms·
You can use polar coordinates; you just have to be sure to correct for the pinching of a polar coordinate system, which will bunch your samples toward the poles
by tbabb 9y ago
You can use polar coordinates; you just have to be sure to correct for the pinching of a polar coordinate system, which will bunch your samples toward the poles.
This gets more complicated in higher dimensions, and at that point it is easier (and perhaps cheaper) to do the gaussian thing. But for 3D it is reasonable if you get your math right.
Another option is to pick a random point inside the unit (hyper-)cube with a uniform random coordinate along each axis, and merely re-roll if your point falls outside the sphere. This gets worse and worse in higher dimensions, though, as the volume of the ball shrinks relative to the volume of the cube.