View Full Version : biased rand();
samel 12-08-2005, 02:29 PM hello..
i did some particle-scripting for a project at work when i noticed that it would be convenient to sometimes be able to bias the rand() function.. does anyone know how to do that..?
/samel
|
|
Bonedaddy
12-08-2005, 02:39 PM
Look up the seed command. I always seed according to particleId when I need something reproducable.
samel
12-08-2005, 03:04 PM
hey, thats a nifty little command.. however..not really what i was looking for ..i want
to have control over where a rand() produces more or less output..
like a logarithmic curve...
//s
brubin
12-08-2005, 03:14 PM
hello..
i did some particle-scripting for a project at work when i noticed that it would be convenient to sometimes be able to bias the rand() function.. does anyone know how to do that..?
/samel
another suggestion:
int $randNumber ;
// if the particleId is a number devideable by 3
if(particleId % 3 == 0)
$randNumber = rand(5,10) ; // put a weight on returning numbers to be between 5 and 10
else
$randNumber = (0,10) ; // otherwise be random on a larger scale
does that help?
s
harmless
12-08-2005, 03:23 PM
define a float called $pwr
get a random number between zero and one based on the id
raise this number to the power of $pwr
cast this result as an integer because maya is...
remap this zero to one range from $min to $max where you define $min and $max
float $pwr = 3;
float $r = `rand $id 1`;
int $r = pow($r,$pwr);
float $lifeTime = `rand $r $minLife $maxLife`;
samel
12-09-2005, 09:14 AM
thanks guys.. works ok.. need to tweak things somewhat but these are good starts..
//s
CGTalk Moderation
12-09-2005, 09:14 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.