From 045072746d766d61284a82dd566b65fd907d2c97 Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Sat, 23 Mar 2013 20:19:39 +0000 Subject: [PATCH] Cleaning up extraneous namespace references --- gtsam_unstable/geometry/SimPolygon2D.cpp | 19 ++++----- gtsam_unstable/geometry/SimPolygon2D.h | 42 +++++++++---------- gtsam_unstable/geometry/SimWall2D.cpp | 11 +++-- gtsam_unstable/geometry/SimWall2D.h | 22 +++++----- .../geometry/tests/testSimPolygon2D.cpp | 1 - .../geometry/tests/testSimWall2D.cpp | 1 - 6 files changed, 46 insertions(+), 50 deletions(-) diff --git a/gtsam_unstable/geometry/SimPolygon2D.cpp b/gtsam_unstable/geometry/SimPolygon2D.cpp index 8667d0807..bc22cb024 100644 --- a/gtsam_unstable/geometry/SimPolygon2D.cpp +++ b/gtsam_unstable/geometry/SimPolygon2D.cpp @@ -15,7 +15,6 @@ namespace gtsam { using namespace std; -using namespace gtsam; const size_t max_it = 100000; boost::minstd_rand SimPolygon2D::rng(42u); @@ -128,7 +127,7 @@ SimPolygon2D SimPolygon2D::randomTriangle( double side_len, double mean_side_len, double sigma_side_len, double min_vertex_dist, double min_side_len, const vector& existing_polys) { // get the current set of landmarks - std::vector lms; + std::vector lms; double d2 = side_len/2.0; lms.push_back(Point2( d2, d2)); lms.push_back(Point2(-d2, d2)); @@ -150,7 +149,7 @@ SimPolygon2D SimPolygon2D::randomTriangle( // extend from B to find C double dBC = randomDistance(mean_side_len, sigma_side_len, min_side_len); - Pose2 xC = xB.retract(gtsam::delta(3, 0, dBC)); + Pose2 xC = xB.retract(delta(3, 0, dBC)); // use triangle equality to verify non-degenerate triangle double dAC = xA.t().dist(xC.t()); @@ -183,7 +182,7 @@ SimPolygon2D SimPolygon2D::randomRectangle( double side_len, double mean_side_len, double sigma_side_len, double min_vertex_dist, double min_side_len, const vector& existing_polys) { // get the current set of landmarks - std::vector lms; + std::vector lms; double d2 = side_len/2.0; lms.push_back(Point2( d2, d2)); lms.push_back(Point2(-d2, d2)); @@ -267,7 +266,7 @@ Point2 SimPolygon2D::randomBoundedPoint2(double boundary_size, /* ***************************************************************** */ Point2 SimPolygon2D::randomBoundedPoint2(double boundary_size, - const std::vector& landmarks, double min_landmark_dist) { + const std::vector& landmarks, double min_landmark_dist) { for (size_t i=0; i& landmarks, + const std::vector& landmarks, const vector& obstacles, double min_landmark_dist) { for (size_t i=0; i& landmarks, + const Point2& LL_corner, const Point2& UR_corner, + const std::vector& landmarks, const std::vector& obstacles, double min_landmark_dist) { boost::uniform_real<> gen_x(0.0, UR_corner.x() - LL_corner.x()); @@ -319,9 +318,9 @@ bool SimPolygon2D::insideBox(double s, const Point2& p) { } /* ***************************************************************** */ -bool SimPolygon2D::nearExisting(const std::vector& S, +bool SimPolygon2D::nearExisting(const std::vector& S, const Point2& p, double threshold) { - BOOST_FOREACH(const gtsam::Point2& Sp, S) + BOOST_FOREACH(const Point2& Sp, S) if (Sp.dist(p) < threshold) return true; return false; diff --git a/gtsam_unstable/geometry/SimPolygon2D.h b/gtsam_unstable/geometry/SimPolygon2D.h index d8e56e998..504c2fa46 100644 --- a/gtsam_unstable/geometry/SimPolygon2D.h +++ b/gtsam_unstable/geometry/SimPolygon2D.h @@ -18,7 +18,7 @@ namespace gtsam { */ class SimPolygon2D { protected: - std::vector landmarks_; + std::vector landmarks_; static boost::minstd_rand rng; public: @@ -30,13 +30,13 @@ public: static void seedGenerator(unsigned long seed); /** Named constructor for creating triangles */ - static SimPolygon2D createTriangle(const gtsam::Point2& pA, const gtsam::Point2& pB, const gtsam::Point2& pC); + static SimPolygon2D createTriangle(const Point2& pA, const Point2& pB, const Point2& pC); /** * Named constructor for creating axis-aligned rectangles * @param p is the lower-left corner */ - static SimPolygon2D createRectangle(const gtsam::Point2& p, double height, double width); + static SimPolygon2D createRectangle(const Point2& p, double height, double width); /** * Randomly generate a triangle that does not conflict with others @@ -55,9 +55,9 @@ public: double min_vertex_dist, double min_side_len, const std::vector& existing_polys); // access to underlying points - const gtsam::Point2& landmark(size_t i) const { return landmarks_[i]; } + const Point2& landmark(size_t i) const { return landmarks_[i]; } size_t size() const { return landmarks_.size(); } - const std::vector& vertices() const { return landmarks_; } + const std::vector& vertices() const { return landmarks_; } // testable requirements bool equals(const SimPolygon2D& p, double tol=1e-5) const; @@ -73,7 +73,7 @@ public: * Polygons are closed, convex shapes. * @return true if the given point is contained by this polygon */ - bool contains(const gtsam::Point2& p) const; + bool contains(const Point2& p) const; /** * Checks two polygons to determine if they overlap @@ -82,48 +82,48 @@ public: bool overlaps(const SimPolygon2D& p) const; /** returns true iff p is contained in any of a set of polygons */ - static bool anyContains(const gtsam::Point2& p, const std::vector& obstacles); + static bool anyContains(const Point2& p, const std::vector& obstacles); /** returns true iff polygon p overlaps with any of a set of polygons */ static bool anyOverlaps(const SimPolygon2D& p, const std::vector& obstacles); /** returns true iff p is inside a square centered at zero with side s */ - static bool insideBox(double s, const gtsam::Point2& p); + static bool insideBox(double s, const Point2& p); /** returns true iff p is within threshold of any point in S */ - static bool nearExisting(const std::vector& S, - const gtsam::Point2& p, double threshold); + static bool nearExisting(const std::vector& S, + const Point2& p, double threshold); /** pick a random point uniformly over a box of side s */ - static gtsam::Point2 randomPoint2(double s); + static Point2 randomPoint2(double s); /** randomly generate a Rot2 with a uniform distribution over theta */ - static gtsam::Rot2 randomAngle(); + static Rot2 randomAngle(); /** generate a distance from a normal distribution given a mean and sigma */ static double randomDistance(double mu, double sigma, double min_dist = -1.0); /** pick a random point within a box that is further than dist d away from existing landmarks */ - static gtsam::Point2 randomBoundedPoint2(double boundary_size, - const std::vector& landmarks, double min_landmark_dist); + static Point2 randomBoundedPoint2(double boundary_size, + const std::vector& landmarks, double min_landmark_dist); /** pick a random point within a box that meets above requirements, as well as staying out of obstacles */ - static gtsam::Point2 randomBoundedPoint2(double boundary_size, - const std::vector& landmarks, + static Point2 randomBoundedPoint2(double boundary_size, + const std::vector& landmarks, const std::vector& obstacles, double min_landmark_dist); /** pick a random point that only avoid obstacles */ - static gtsam::Point2 randomBoundedPoint2(double boundary_size, + static Point2 randomBoundedPoint2(double boundary_size, const std::vector& obstacles); /** pick a random point in box defined by lower left and upper right corners */ - static gtsam::Point2 randomBoundedPoint2( - const gtsam::Point2& LL_corner, const gtsam::Point2& UR_corner, - const std::vector& landmarks, + static Point2 randomBoundedPoint2( + const Point2& LL_corner, const Point2& UR_corner, + const std::vector& landmarks, const std::vector& obstacles, double min_landmark_dist); /** pick a random pose in a bounded area that is not in an obstacle */ - static gtsam::Pose2 randomFreePose(double boundary_size, const std::vector& obstacles); + static Pose2 randomFreePose(double boundary_size, const std::vector& obstacles); }; diff --git a/gtsam_unstable/geometry/SimWall2D.cpp b/gtsam_unstable/geometry/SimWall2D.cpp index d086aa735..b03f52890 100644 --- a/gtsam_unstable/geometry/SimWall2D.cpp +++ b/gtsam_unstable/geometry/SimWall2D.cpp @@ -11,7 +11,6 @@ namespace gtsam { using namespace std; -using namespace gtsam; /* ************************************************************************* */ void SimWall2D::print(const std::string& s) const { @@ -26,7 +25,7 @@ bool SimWall2D::equals(const SimWall2D& other, double tol) const { } /* ************************************************************************* */ -bool SimWall2D::intersects(const SimWall2D& B, boost::optional pt) const { +bool SimWall2D::intersects(const SimWall2D& B, boost::optional pt) const { const bool debug = false; const SimWall2D& A = *this; @@ -101,7 +100,7 @@ bool SimWall2D::intersects(const SimWall2D& B, boost::optional p } /* ************************************************************************* */ -gtsam::Point2 SimWall2D::midpoint() const { +Point2 SimWall2D::midpoint() const { Point2 vec = b_ - a_; return a_ + vec * 0.5 * vec.norm(); } @@ -123,9 +122,9 @@ Rot2 SimWall2D::reflection(const Point2& init, const Point2& intersection) const } /* ***************************************************************** */ -std::pair moveWithBounce(const gtsam::Pose2& cur_pose, double step_size, - const std::vector walls, gtsam::Sampler& angle_drift, - gtsam::Sampler& reflect_noise, const gtsam::Rot2& bias) { +std::pair moveWithBounce(const Pose2& cur_pose, double step_size, + const std::vector walls, Sampler& angle_drift, + Sampler& reflect_noise, const Rot2& bias) { // calculate angle to change by Rot2 dtheta = Rot2::fromAngle(angle_drift.sample()(0) + bias.theta()); diff --git a/gtsam_unstable/geometry/SimWall2D.h b/gtsam_unstable/geometry/SimWall2D.h index f11e8dfd2..0b8328baa 100644 --- a/gtsam_unstable/geometry/SimWall2D.h +++ b/gtsam_unstable/geometry/SimWall2D.h @@ -17,14 +17,14 @@ namespace gtsam { */ class SimWall2D { protected: - gtsam::Point2 a_, b_; + Point2 a_, b_; public: /** default constructor makes canonical wall */ SimWall2D() : a_(1.0, 0.0), b_(1.0, 1.0) {} /** constructors using endpoints */ - SimWall2D(const gtsam::Point2& a, const gtsam::Point2& b) + SimWall2D(const Point2& a, const Point2& b) : a_(a), b_(b) {} SimWall2D(double ax, double ay, double bx, double by) @@ -35,33 +35,33 @@ namespace gtsam { bool equals(const SimWall2D& other, double tol=1e-9) const; /** access */ - gtsam::Point2 a() const { return a_; } - gtsam::Point2 b() const { return b_; } + Point2 a() const { return a_; } + Point2 b() const { return b_; } /** scales a wall to produce a new wall */ SimWall2D scale(double s) const { return SimWall2D(s*a_, s*b_); } /** geometry */ double length() const { return a_.dist(b_); } - gtsam::Point2 midpoint() const; + Point2 midpoint() const; /** * intersection check between two segments * returns true if they intersect, with the intersection * point in the optional second argument */ - bool intersects(const SimWall2D& wall, boost::optional pt=boost::none) const; + bool intersects(const SimWall2D& wall, boost::optional pt=boost::none) const; /** * norm is a 2D point representing the norm of the wall */ - gtsam::Point2 norm() const; + Point2 norm() const; /** * reflection around a point of impact with a wall from a starting (init) point * at a given impact point (intersection), returning the angle away from the impact */ - gtsam::Rot2 reflection(const gtsam::Point2& init, const gtsam::Point2& intersection) const; + Rot2 reflection(const Point2& init, const Point2& intersection) const; }; @@ -78,8 +78,8 @@ namespace gtsam { * @return the next pose for the robot * NOTE: samplers cannot be const */ - std::pair moveWithBounce(const gtsam::Pose2& cur_pose, double step_size, - const std::vector walls, gtsam::Sampler& angle_drift, - gtsam::Sampler& reflect_noise, const gtsam::Rot2& bias = gtsam::Rot2()); + std::pair moveWithBounce(const Pose2& cur_pose, double step_size, + const std::vector walls, Sampler& angle_drift, + Sampler& reflect_noise, const Rot2& bias = Rot2()); } // \namespace gtsam diff --git a/gtsam_unstable/geometry/tests/testSimPolygon2D.cpp b/gtsam_unstable/geometry/tests/testSimPolygon2D.cpp index 9a0ba204a..37cdfa0ba 100644 --- a/gtsam_unstable/geometry/tests/testSimPolygon2D.cpp +++ b/gtsam_unstable/geometry/tests/testSimPolygon2D.cpp @@ -9,7 +9,6 @@ using namespace std; using namespace gtsam; -using namespace gtsam; const double tol=1e-5; diff --git a/gtsam_unstable/geometry/tests/testSimWall2D.cpp b/gtsam_unstable/geometry/tests/testSimWall2D.cpp index 36eaa35e5..62f458402 100644 --- a/gtsam_unstable/geometry/tests/testSimWall2D.cpp +++ b/gtsam_unstable/geometry/tests/testSimWall2D.cpp @@ -8,7 +8,6 @@ #include -using namespace gtsam; using namespace gtsam; const double tol = 1e-5;