Exemplo n.º 1
0
bool Random::metropolis(double ratio) {
  if (ratio > 1.0) {
    return true;
  } else {
    double ran = uniformReal();
    if (ran < ratio) {
      return true;
    } else {
      return false;
    }
  }
}
Exemplo n.º 2
0
// See: http://math.stackexchange.com/a/87238
void ompl::RNG::uniformInBall(double r, unsigned int n, double value[])
{
    // Draw a random point on the unit sphere
    uniformNormalVector(n, value);

    // Draw a random radius scale
    double radiusScale = r * std::pow(uniformReal(0.0, 1.0), 1.0 / static_cast<double>(n));

    // Scale the point on the unit sphere
    for (unsigned int i = 0u; i < n; ++i)
    {
        value[i] = radiusScale * value[i];
    }
}
Exemplo n.º 3
0
Vector3D Random::randomVector(Vector3D min, Vector3D max) {
  return Vector3D(uniformReal(min.x, max.x),
                  uniformReal(min.y, max.y),
                  uniformReal(min.z, max.z));
}
Exemplo n.º 4
0
Vector3D Random::randomVector() {
  return Vector3D(uniformReal(),
                  uniformReal(),
                  uniformReal());
}