void generate_darts(vector<Point_2> &points, unsigned npoints, MTRand &rng)
{
    const double rnorm  = 0.725;
    const double mdnorm = sqrt(SQRT3 * 0.5 * npoints);
    const double md     = rnorm / mdnorm;
    const double sqr_md = md * md;
    
    points.reserve(npoints);
    while (points.size() < npoints) {
        while (true) {
            Point_2 cand(rng.randExc(), rng.randExc());
            bool hit = true;
            for (unsigned i = 0; i < points.size(); ++i) {
                if (sqr_dist_unit_torus(cand, points[i]) < sqr_md) {
                    hit = false;
                    break;
                }
            }
            if (hit) {
                points.push_back(cand);
                break;
            }
        }
    }
}
void generate_random(vector<Point_2> &points, unsigned npoints, MTRand &rng)
{
    points.reserve(npoints);
    for (unsigned i = 0; i < npoints; ++i) {
        Point_2 p(rng.randExc(), rng.randExc());
        points.push_back(p);
    }
}
Example #3
0
/**************************************************************************//**
 *  Return a random position inside the cylinder.
******************************************************************************/
dVec Cylinder::randPosition(MTRand &random) const {

    dVec randPos;
    double r = 0.5*side[0]*random.randExc();
    double phi = random.randExc(2.0*M_PI);
    randPos[0] = r * cos(phi);
    randPos[1] = r * sin(phi);
    randPos[2] = side[2]*(-0.5 + random.randExc());

    return randPos;
}
Example #4
0
double ran(){
  //<<<<<<< HEAD
  MTRand random;
  random.seed();
  return random.rand();
  // return rand()/double(RAND_MAX);
  //=======
  static MTRand my_mtrand;
  return my_mtrand.randExc(); // which is the range of [0,1)
  //>>>>>>> 2511a06ab322dcea9f3f70080c443d0938562932
}
Example #5
0
/**************************************************************************//**
 *  Return a random position inside the cube.
******************************************************************************/
dVec Prism::randPosition(MTRand &random) const {
    dVec randPos;
    for (int i = 0; i < NDIM; i++)
        randPos[i] = side[i]*(-0.5 + random.randExc());
    return randPos;
}
Example #6
0
float rand_chance_f(void)
{
    return (float)mtRand.randExc(100.0);
}
Example #7
0
double rand_chance(void)
{
    return mtRand.randExc(100.0);
}
Example #8
0
float rand_norm_f(void)
{
    return (float)mtRand.randExc();
}
Example #9
0
double rand_norm(void)
{
    return mtRand.randExc();
}
Example #10
0
float frand(float min, float max)
{
	return (float)(mtRand.randExc(max - min) + min);
}