On Tue, Mar 2, 2010 at 3:44 PM, Jos Timanta Tarigan <jos_t_tari...@yahoo.com> wrote: > Hi, > > i need help translating a class, i hope you guys dont mind i put the whole > code in here. > honestly speaking i dont understand what it did from top to bottom but i know > the intention > is to build a random value. the problem is i dont know if this random has > some kind of > constraint or its pure random. > > so im trying to build a ray tracing program. one of the purpose is to create > a random value > to create the ray, some kind of random sampling. if you follow this link: > > http://www.devmaster.net/articles/raytracing_series/part5.php
The answer to your question is actually on that page: # The code also uses a new random number generator: The Mersenne # Twister. This is a random number generator that gives better results # than the build-in Rand() function, and is a bit faster # as well. The Mersenne Twister resides in twister.cpp and twister >From http://en.wikipedia.org/wiki/Mersenne_twister $ For a k-bit word length, the Mersenne Twister generates numbers with $ a uniform distribution in the range [0,2^k - 1]. So, yes, you could replace it with a call to rand(), but it's likely to be slower. Given one of those images took 11 minutes to produce (back in 2005) I've no idea how much slower it is. -- PJH http://shabbleland.myminicity.com/env http://www.chavgangs.com/register.php?referer=9375