|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
09-22-2008 04:56
HIyas Everyone, Can someone help me out with the math here? I would like to use llFrand to generate random RADIUS for particles. There is always a minimum distance of 1.75M that I want to maintain. And I have a MAX_RADIUS that I use as a variable. This is one of the ways I've tried but the particles do seem to bunch up at the 1.75M mark. And other ways that I've tried adds 1.75M to MAX_RADIUS. I would just like to keep it all between 1.75M and MAX_RAD. All help will be greatly appreciated.  float MAX_RAD = 5.0; // Max Radius Value float trad; // Temp Radius Value float RADIUS; // Particle Radius timer() { trad = llFrand(MAX_RAD); {if(RAD<1.75) RADIUS = 1.75; else RADIUS = trad; } ParticleFunction(); }
|
|
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
|
09-22-2008 05:28
trad = llFrand( MAX_RAD - 1.75 ); //Generate a random number up to 1.75 less than MAX_RAD. RADIUS = 1.75 + trad; // add 1.75 to randomly-generated number above, ensuring it is always at least 1.75.
|
|
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
|
09-22-2008 05:32
Yes, that function will tend to bunch them up at 1.75. The number you want to feed the random number function is the difference between your max and min, and then you want to add your min to the result.
float MIN_RAD = 1.75; float MAX_RAD = 5.; float rad;
timer() { rad = llFrand( MAX_RAD - MIN_RAD) + MIN_RAD; }
|
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
09-22-2008 05:42
Thanx Deanna and Anya! 
|