From 27a86352d718fb8ac866dbc34299f756a3abdc79 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Wed, 12 Feb 2014 17:15:02 -0500 Subject: [PATCH] boost::random namespace fixes in geometry --- gtsam/geometry/Rot3.cpp | 4 ++-- gtsam/geometry/Rot3.h | 2 +- gtsam/geometry/Sphere2.cpp | 4 ++-- gtsam/geometry/Sphere2.h | 15 ++------------- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/gtsam/geometry/Rot3.cpp b/gtsam/geometry/Rot3.cpp index 72124d25d..3cb41e936 100644 --- a/gtsam/geometry/Rot3.cpp +++ b/gtsam/geometry/Rot3.cpp @@ -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 :-( Sphere2 w = Sphere2::Random(rng); - boost::random::uniform_real_distribution randomAngle(-M_PI,M_PI); + boost::uniform_real randomAngle(-M_PI,M_PI); double angle = randomAngle(rng); return rodriguez(w,angle); } diff --git a/gtsam/geometry/Rot3.h b/gtsam/geometry/Rot3.h index 847d31d65..83232ea02 100644 --- a/gtsam/geometry/Rot3.h +++ b/gtsam/geometry/Rot3.h @@ -104,7 +104,7 @@ namespace gtsam { Rot3(const Quaternion& q); /// 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 ~Rot3() {} diff --git a/gtsam/geometry/Sphere2.cpp b/gtsam/geometry/Sphere2.cpp index ed2561e22..6acb06dde 100644 --- a/gtsam/geometry/Sphere2.cpp +++ b/gtsam/geometry/Sphere2.cpp @@ -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 :-( - boost::random::uniform_on_sphere randomDirection(3); + boost::uniform_on_sphere randomDirection(3); vector d = randomDirection(rng); Sphere2 result; result.p_ = Point3(d[0], d[1], d[2]); diff --git a/gtsam/geometry/Sphere2.h b/gtsam/geometry/Sphere2.h index d4047f421..82c6bb3d7 100644 --- a/gtsam/geometry/Sphere2.h +++ b/gtsam/geometry/Sphere2.h @@ -22,23 +22,12 @@ #include #include +#include #ifndef SPHERE2_DEFAULT_COORDINATES_MODE #define SPHERE2_DEFAULT_COORDINATES_MODE Sphere2::RENORM #endif -// (Cumbersome) forward declaration for random generator -namespace boost { -namespace random { -template -class mersenne_twister_engine; -typedef mersenne_twister_engine mt19937; -} -} - namespace gtsam { /// Represents a 3D point on a unit sphere. @@ -75,7 +64,7 @@ public: boost::optional H = boost::none); /// Random direction, using boost::uniform_on_sphere - static Sphere2 Random(boost::random::mt19937 & rng); + static Sphere2 Random(boost::mt19937 & rng); /// @}