boost::random namespace fixes in geometry
parent
5ecfac348c
commit
27a86352d7
|
|
@ -45,10 +45,10 @@ Rot3 Rot3::rodriguez(const Sphere2& w, double theta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
Rot3 Rot3::Random(boost::random::mt19937 & rng) {
|
Rot3 Rot3::Random(boost::mt19937 & rng) {
|
||||||
// TODO allow any engine without including all of boost :-(
|
// TODO allow any engine without including all of boost :-(
|
||||||
Sphere2 w = Sphere2::Random(rng);
|
Sphere2 w = Sphere2::Random(rng);
|
||||||
boost::random::uniform_real_distribution<double> randomAngle(-M_PI,M_PI);
|
boost::uniform_real<double> randomAngle(-M_PI,M_PI);
|
||||||
double angle = randomAngle(rng);
|
double angle = randomAngle(rng);
|
||||||
return rodriguez(w,angle);
|
return rodriguez(w,angle);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ namespace gtsam {
|
||||||
Rot3(const Quaternion& q);
|
Rot3(const Quaternion& q);
|
||||||
|
|
||||||
/// Random, generates a random axis, then random angle \in [-p,pi]
|
/// Random, generates a random axis, then random angle \in [-p,pi]
|
||||||
static Rot3 Random(boost::random::mt19937 & rng);
|
static Rot3 Random(boost::mt19937 & rng);
|
||||||
|
|
||||||
/** Virtual destructor */
|
/** Virtual destructor */
|
||||||
virtual ~Rot3() {}
|
virtual ~Rot3() {}
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@ Sphere2 Sphere2::FromPoint3(const Point3& point,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
Sphere2 Sphere2::Random(boost::random::mt19937 & rng) {
|
Sphere2 Sphere2::Random(boost::mt19937 & rng) {
|
||||||
// TODO allow any engine without including all of boost :-(
|
// TODO allow any engine without including all of boost :-(
|
||||||
boost::random::uniform_on_sphere<double> randomDirection(3);
|
boost::uniform_on_sphere<double> randomDirection(3);
|
||||||
vector<double> d = randomDirection(rng);
|
vector<double> d = randomDirection(rng);
|
||||||
Sphere2 result;
|
Sphere2 result;
|
||||||
result.p_ = Point3(d[0], d[1], d[2]);
|
result.p_ = Point3(d[0], d[1], d[2]);
|
||||||
|
|
|
||||||
|
|
@ -22,23 +22,12 @@
|
||||||
|
|
||||||
#include <gtsam/geometry/Point3.h>
|
#include <gtsam/geometry/Point3.h>
|
||||||
#include <gtsam/base/DerivedValue.h>
|
#include <gtsam/base/DerivedValue.h>
|
||||||
|
#include <boost/random/mersenne_twister.hpp>
|
||||||
|
|
||||||
#ifndef SPHERE2_DEFAULT_COORDINATES_MODE
|
#ifndef SPHERE2_DEFAULT_COORDINATES_MODE
|
||||||
#define SPHERE2_DEFAULT_COORDINATES_MODE Sphere2::RENORM
|
#define SPHERE2_DEFAULT_COORDINATES_MODE Sphere2::RENORM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// (Cumbersome) forward declaration for random generator
|
|
||||||
namespace boost {
|
|
||||||
namespace random {
|
|
||||||
template<class UIntType, std::size_t w, std::size_t n, std::size_t m,
|
|
||||||
std::size_t r, UIntType a, std::size_t u, UIntType d, std::size_t s,
|
|
||||||
UIntType b, std::size_t t, UIntType c, std::size_t l, UIntType f>
|
|
||||||
class mersenne_twister_engine;
|
|
||||||
typedef mersenne_twister_engine<uint32_t, 32, 624, 397, 31, 0x9908b0df, 11,
|
|
||||||
0xffffffff, 7, 0x9d2c5680, 15, 0xefc60000, 18, 1812433253> mt19937;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
/// Represents a 3D point on a unit sphere.
|
/// Represents a 3D point on a unit sphere.
|
||||||
|
|
@ -75,7 +64,7 @@ public:
|
||||||
boost::optional<Matrix&> H = boost::none);
|
boost::optional<Matrix&> H = boost::none);
|
||||||
|
|
||||||
/// Random direction, using boost::uniform_on_sphere
|
/// Random direction, using boost::uniform_on_sphere
|
||||||
static Sphere2 Random(boost::random::mt19937 & rng);
|
static Sphere2 Random(boost::mt19937 & rng);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue