bool Random::metropolis(double ratio) { if (ratio > 1.0) { return true; } else { double ran = uniformReal(); if (ran < ratio) { return true; } else { return false; } } }
// 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]; } }
Vector3D Random::randomVector(Vector3D min, Vector3D max) { return Vector3D(uniformReal(min.x, max.x), uniformReal(min.y, max.y), uniformReal(min.z, max.z)); }
Vector3D Random::randomVector() { return Vector3D(uniformReal(), uniformReal(), uniformReal()); }