|
|
Wolfgang Wieser wrote:
> 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 - ;)
>
As shown last time, we already have a function for the uniform
distribution on a sphere surface. For the VRand_In_Sphere() function,
it is therefore sufficient to prove that the radius calculation
(i.e. vector length) is correct.
For that purpose, it must be shown that the probability for the
vector being of a certain length range is equal to the volume
enclosed by that radius range (divided by 4*pi/3, of course).
The sphere volume between radii r1 and r2 (r2>r1) is:
V = 4*pi/3 * (r2^3 - r1^3)
The vector length l is calculated as l=a^(1/3) with a=rand(Stream),
hence l^3 is uniformly distributed in the range 0..1.
The probability for the vector to end in the volume V (i.e. radius
range r1..r2) is:
P(vector in V) = P(r1 <= l < r2) = P(r1^3 <= l^3 < r2^3) =
and as l^3=a:
= P(r1^3 <= a < r2^3) = r2^3 - r1^3
Hence, the quotient (probability per volume) is:
P/V = 3/(4*Pi)
...which is what we want.
- q.e.d.
So, it works; VRand_In_Sphere() is uniformly distributed in the sphere.
Any doubts or problems?
Wolfgang
Post a reply to this message
|
|