POV-Ray : Newsgroups : povray.text.scene-files : Gaussian random numbers : Gaussian random numbers Server Time
5 Jul 2024 12:13:30 EDT (-0400)
  Gaussian random numbers  
From: Reusser
Date: 30 Jun 2001 16:09:56
Message: <3B3E30F6.571583F5@chorus.net>
I looked online and found quite a useful equation for generating
gaussian random nubmers.  This macro generates a random number that is
roughly between -3 and 3.  The numbers will be normally distributed
(mean = 0 standard deviation 1).

This is very useful for something like randomly rotating bricks or
tiles.  Using the pov-ray random function, they would all be rotated
randomly from 0 degrees to x degrees, but with this macro, about 2/3 are
between 0 and x degrees while there are a few outliers.  It gives it a
more natural look.

 - Rico


Here's the site in case someone wants to take a look at the second
equation (I couldn't get it to work correctly):

http://www.taygeta.com/random/gaussian.html

And here's the macro:

#declare e = 2.718281828459;
#macro gauss(RSR)
  sqrt(-2*log(rand(RSR))/log(e))*cos(2*pi*rand(RSR))
#end


Post a reply to this message

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