POV-Ray : Newsgroups : povray.off-topic : Random vector through a hemisphere? : Re: Random vector through a hemisphere? Server Time
11 Oct 2024 03:14:44 EDT (-0400)
  Re: Random vector through a hemisphere?  
From: scott
Date: 18 Feb 2008 07:15:42
Message: <47b976ee$1@news.povray.org>
> Ok, that makes me wonder, because:
>
> 1. The 2 methods above produce 100% identical images. It was a scene of
> one light emitting sphere, ground and 3 diffusing spheres of different
> colors. (I did use the cosine ratio relative to the angle of light
> falling on surface.) I can post the images if needed. The only
> difference is that the second method is faster - with a great margin.
>
> 2. If the distribution is not identical by the 2 methods, why are the
> images still 100% identical?

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.


Post a reply to this message

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