And this is the code I use: double x,y,z; do{ x = 2.0 * rNG.randomNumberClosed() - 1.0; z = 2.0 * rNG.randomNumberClosed() - 1.0; } while(x*x + z*z > 1.0); y = sqrt(1.0 - (x*x + z*z)); There you have it: a random vector inside a hemishere.
Post a reply to this message