void VoxSprite::chooseRandomDir() { int d = int( randUniform() * 5.0 ); m_angle = d * 90.0; m_timeout = randNormal( 4.0, 1.0 ); }
void ParticleBuff::emitRadial( ParticleType ptype, float x, float y, float radius ) { Particle *p = emitPart( ptype ); if (!p) return; // Buff full // set up general stuff const float initialVel = 50.0; p->x = x + randNormal() * radius; p->y = y + randNormal() * radius; p->maxAge = 3.0 + randNormal(); if ((ptype==Particle_RIPPLE) || (ptype==Particle_SMOKE)) { p->angle = 0.0; p->dx = 0.0; p->dy = 0.0; } else if (ptype == Particle_DOT) { p->dx = randNormal() * initialVel; p->dy = (1.0+randNormal()) * initialVel; } else { p->angle = randUniform() * 360.0; p->dx = randNormal() * initialVel; p->dy = randNormal() * initialVel; } p->age = 0; }
/*! * Determines and returns the power of the motor in each cycle. * Should be called only once per cycle! */ double cbMotor::outPower() { double noisepow = randNormal(100.0, noise) / 100.0; outpower = (0.5*inpower + 0.5*prevpower) * noisepow; prevpower = outpower; return outpower; }
/* * Method: * void global_test(void) * * Purpose: * Tests the global functions. The pseudorandom distributions * were tested by porting the result to Excel, and looking * at the histogram, the average, and the stdev. * * Input: * none * * Output: * none */ void global_test(void) { // only about 3 values should be beyond the [0,60] interval of 3*stdev around the mean for the normal for( int i=0; i<1000; i++ ) printf("%f\t%f\n", randNormal(30,10), randExponential(10)); alert("test"); char *str = strdup("1Ux:"); printf("%s\n",strlwr(str)); printf("%d\n", stricmp( "A", "a" ) ); printf("%d\n", stricmp( "B", "a" ) ); printf("%d\n", stricmp( "aabDDD", "Edsa" ) ); }
void ParticleBuff::emitRadial( ParticleType ptype, float x, float y, float radius ) { Particle *p = emitPart( ptype ); if (!p) return; // Buff full // set up general stuff const float initialVel = 50.0; p->x = x + randNormal() * radius; p->y = y + randNormal() * radius; p->maxAge = 3.0 + randNormal(); //p->r = 1.0; p->g = 1.0; p->b = 1.0; float t = randUniform(); float rA = 166/255.0; float gA = 202/255.0; float bA = 222/255.0; float rB = 31/255.0; float gB = 45/255.0; float bB = 227/255.0; p->r = (rA*t) + (rB*(1.0-t)); p->g = (gA*t) + (gB*(1.0-t)); p->b = (bA*t) + (bB*(1.0-t)); if ((ptype==Particle_RING) || (ptype==Particle_SMOKE)) { p->angle = randUniform( 0.0, 360.0); p->dx = 0.0; p->dy = 0.0; } else if (ptype == Particle_DOT) { p->dx = randNormal() * initialVel; p->dy = (1.0+randNormal()) * initialVel; } else { p->angle = randUniform() * 360.0; p->dx = randNormal() * initialVel; p->dy = randNormal() * initialVel; } p->age = 0; }
float randNormal( float mean, float stddev ) { return (randNormal() * stddev) + mean; }