diff --git a/gtsam/geometry/Sphere2.cpp b/gtsam/geometry/Sphere2.cpp index 6acb06dde..1dc64312a 100644 --- a/gtsam/geometry/Sphere2.cpp +++ b/gtsam/geometry/Sphere2.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include using namespace std; @@ -47,7 +48,11 @@ Sphere2 Sphere2::FromPoint3(const Point3& point, Sphere2 Sphere2::Random(boost::mt19937 & rng) { // TODO allow any engine without including all of boost :-( boost::uniform_on_sphere randomDirection(3); - vector d = randomDirection(rng); + // This variate_generator object is required for versions of boost somewhere + // around 1.46, instead of drawing directly using boost::uniform_on_sphere(rng). + boost::variate_generator > + generator(rng, randomDirection); + vector d = generator(); Sphere2 result; result.p_ = Point3(d[0], d[1], d[2]); return result; diff --git a/gtsam/geometry/tests/testSphere2.cpp b/gtsam/geometry/tests/testSphere2.cpp index 306d84b94..15bdec407 100644 --- a/gtsam/geometry/tests/testSphere2.cpp +++ b/gtsam/geometry/tests/testSphere2.cpp @@ -312,7 +312,7 @@ TEST(Sphere2, localCoordinates_retract_expmap) { //******************************************************************************* TEST(Sphere2, Random) { - boost::random::mt19937 rng(42); + boost::mt19937 rng(42); // Check that is deterministic given same random seed Point3 expected(-0.667578, 0.671447, 0.321713); Point3 actual = Sphere2::Random(rng).point3();