POV-Ray : Newsgroups : povray.off-topic : Random vector through a hemisphere? : Re: Random vector through a hemisphere? Server Time
11 Oct 2024 03:16:44 EDT (-0400)
  Re: Random vector through a hemisphere?  
From: Severi Salminen
Date: 18 Feb 2008 08:23:19
Message: <47b986c7$1@news.povray.org>
> Actually yes, they are both the same, and wrong ;-)  I hadn't checked
> your y=sqrt(rand()) method, just assumed it was correct.
> 
> A correct way is:
> 
> y = rand(0...1);
> phi = rand(0...2pi)
> x = sqrt(1-y*y) * cos(phi)
> z = sqrt(1-y*y) * sin(phi)
> 
> This will give a more even distribution, if you visualise the results
> you'll see that your earlier attempts don't give many points around the
> equator.

I made finally a test program to see the distribution by looking down
the sphere. It seems that the above method and the first method in this
thread (x= sin(theta)*cos(phi)...) BOTH should NOT have sqrt to produce
even distribution on surface. It also seems that if the sqrt is
included, all 3 methods produce identical distribution which is weighted
to pole -> ie. less points on the equator. Or if you look along y axis,
they have uniform distribution projected on XZ plane.


Post a reply to this message

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