Severi Salminen <sev### [at] not thissaunalahti fi invalid> wrote:
> 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.
You still have to rotate it so that the hemisphere is tangential to
the surface. Probably requires multiplication with a matrix.
--
- Warp
Post a reply to this message
|