POV-Ray : Newsgroups : povray.general : Help with a spherical container : Re: Help with a spherical container Server Time
4 Aug 2024 02:17:39 EDT (-0400)
  Re: Help with a spherical container  
From: Tom Melly
Date: 5 Nov 2003 06:29:33
Message: <3fa8df1d@news.povray.org>
"Tim Nikias v2.0" <tim.nikias (@) nolights.de> wrote in message
news:3fa8d552@news.povray.org...

> Nah, not sure if this is even distribution. Would be, sorta, if the
> rand-function would be TRULY random, but it suffices in most cases anyway.
> Randomizing points in a box and then checking if its in the sphere wouldn't
> produce even distribution either. So why not save the parsing time of
> sorting out unnecessary points?

Ignoring the issue of rand-function and TRULY random, I suspect you're missing
the point.

Imagine a disk, now take a random distance along the radius, and then a random
rotation. You will get a disproportionate number of points near the center of
the disk. However, finding truly random points within a square that contains the
disk, and then checking whether they are inside the disk will produce a proper
random distrib. within the confines of the rand method.

You can see this yourself with the following code:

#include "colors.inc"

camera {
  location  <0.0, 0.0, -4.0>
  look_at   <0.0, 0.0,  0.0>
}

disc {
  <0, 0, 0>  // center position
  z,         // normal vector
  1.0,       // outer radius
  0.0        // optional hole radius
  pigment{Red}
  finish{ambient 1}
}

#local Count = 0;
#local MyRand = seed(2534);
#while(Count<1000)
  sphere{
    0,0.025
    translate y*rand(MyRand)
    rotate z*360*rand(MyRand)
    pigment{Green}
    finish{ambient 1}
  }
  #local Count = Count +1;
#end


Post a reply to this message

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