|
|
> 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
|
|