POV-Ray : Newsgroups : povray.general : Slightly faster VRand_On/In_Sphere() : Re: Slightly faster VRand_On/In_Sphere() Server Time
4 Aug 2024 02:21:25 EDT (-0400)
  Re: Slightly faster VRand_On/In_Sphere()  
From: Wolfgang Wieser
Date: 9 Nov 2003 09:15:17
Message: <3fae4bf4@news.povray.org>
Warp wrote:

> Wolfgang Wieser <wwi### [at] gmxde> wrote:
>> What exactly do you understand by a "proof"?
> 
>   Mathematical proof. Should be unambiguous and checkable by anyone.
> 
Then please check my proof in the other posting(s). 
It should be easy to follow. For convenience, I copy-and-paste 
it here again: 

A: VRand_On_Sphere(): surface vectors. 

The vector is rotated by a random amount around the Y axis, so it 
is sufficient to prove that the probability for the vector being 
in a certain latitude range is equal to the area covered by it 
(divided by 4pi, of course). 

The area size on a sphere between latitudes theta1 and theta2 
is (where theta is not really the latitude but measured downwards from 
the pole): 

which is


The probability for the vector to be inside that area is: 

where y=2*rand(Stream)-1, i.e. uniformly distributed, so 

(because y = r * cos(theta) and r=1 here). 

Now, the probability per area can be calculated as: 

...which is just what we expect and independent of theta1 and theta2. 

- q.e.d. 

So, it works for the sphere surface vectors. 

B: VRand_In_Sphere(), full sphere. 

For the full sphere, there is not much difference, just the 
radius is chosen to be randomly distributed using 
pow(rand(Stream),1/3)). 
I don't believe that this is right until someone (me?) proves 
it to be right - ;)

Wolfgang


Post a reply to this message

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