Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A very simple solution is to generate a 3D point in [-1,1]^3, regenerate if it's length is >1 and project it on to the sphere otherwise.


Why would you regenerate it if the length exceeds 1? Can't you just normalize the vector regardless of its length (excluding 0)?


That would lead to the distribution being non-uniform: there would be more points in the corners of the cube.


Ah, of course. To visualize it, the distance between the center and the surface of the shape would be proportional to the probability of that vector being selected after normalization. Thanks!


Because that would bias the distribution to the corners of the cube.


Since the box is anisotropic, this would not give the uniform distribution (it's more likely to draw a "diagonal" direction than a coordinate axis direction).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: