POV-Ray : Newsgroups : povray.off-topic : Random vector through a hemisphere? : Re: Random vector through a hemisphere? Server Time
10 Oct 2024 21:15:39 EDT (-0400)
  Re: Random vector through a hemisphere?  
From: Severi Salminen
Date: 18 Feb 2008 05:15:35
Message: <47b95ac7$1@news.povray.org>
Severi Salminen wrote:

> I also tried that:
> 
> 
>     do{
>         x = (double) 2.0*rand()/RAND_MAX -1.0;
>         z = (double) 2.0*rand()/RAND_MAX-1.0;
>     }
>     while(x*x+z*z > 1.0);
> 
>     y = sqrt(1.0-(x*x+z*z));
> 
> And the results are very close to the 2 other methods.

And this is also the fastest algorithm of the tree.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.