gtsam 4.2
gtsam
Loading...
Searching...
No Matches
gtsam::SimPolygon2D Class Reference

Detailed Description

General polygon class for convex polygons.

Public Member Functions

 SimPolygon2D ()
 Don't use this constructor, use a named one instead.
const Point2landmark (size_t i) const
size_t size () const
const Point2Vector & vertices () const
bool equals (const SimPolygon2D &p, double tol=1e-5) const
void print (const std::string &s="") const
std::vector< SimWall2Dwalls () const
 Get a set of walls along the edges.
bool contains (const Point2 &p) const
 Core function for randomly generating scenarios.
bool overlaps (const SimPolygon2D &p) const
 Checks two polygons to determine if they overlap.

Static Public Member Functions

static void seedGenerator (unsigned long seed)
 seed the random number generator - only needs to be done once
static SimPolygon2D createTriangle (const Point2 &pA, const Point2 &pB, const Point2 &pC)
 Named constructor for creating triangles.
static SimPolygon2D createRectangle (const Point2 &p, double height, double width)
 Named constructor for creating axis-aligned rectangles.
static SimPolygon2D randomTriangle (double side_len, double mean_side_len, double sigma_side_len, double min_vertex_dist, double min_side_len, const std::vector< SimPolygon2D > &existing_polys)
 Randomly generate a triangle that does not conflict with others Uniformly distributed over box area, with normally distributed lengths of edges THROWS: std::runtime_error if can't find a position.
static SimPolygon2D randomRectangle (double side_len, double mean_side_len, double sigma_side_len, double min_vertex_dist, double min_side_len, const std::vector< SimPolygon2D > &existing_polys)
 Randomly generate a rectangle that does not conflict with others Uniformly distributed over box area, with normally distributed lengths of edges THROWS: std::runtime_error if can't find a position.
static bool anyContains (const Point2 &p, const std::vector< SimPolygon2D > &obstacles)
 returns true iff p is contained in any of a set of polygons
static bool anyOverlaps (const SimPolygon2D &p, const std::vector< SimPolygon2D > &obstacles)
 returns true iff polygon p overlaps with any of a set of polygons
static bool insideBox (double s, const Point2 &p)
 returns true iff p is inside a square centered at zero with side s
static bool nearExisting (const Point2Vector &S, const Point2 &p, double threshold)
 returns true iff p is within threshold of any point in S
static Point2 randomPoint2 (double s)
 pick a random point uniformly over a box of side s
static Rot2 randomAngle ()
 randomly generate a Rot2 with a uniform distribution over theta
static double randomDistance (double mu, double sigma, double min_dist=-1.0)
 generate a distance from a normal distribution given a mean and sigma
static Point2 randomBoundedPoint2 (double boundary_size, const Point2Vector &landmarks, double min_landmark_dist)
 pick a random point within a box that is further than dist d away from existing landmarks
static Point2 randomBoundedPoint2 (double boundary_size, const Point2Vector &landmarks, const std::vector< SimPolygon2D > &obstacles, double min_landmark_dist)
 pick a random point within a box that meets above requirements, as well as staying out of obstacles
static Point2 randomBoundedPoint2 (double boundary_size, const std::vector< SimPolygon2D > &obstacles)
 pick a random point that only avoid obstacles
static Point2 randomBoundedPoint2 (const Point2 &LL_corner, const Point2 &UR_corner, const Point2Vector &landmarks, const std::vector< SimPolygon2D > &obstacles, double min_landmark_dist)
 pick a random point in box defined by lower left and upper right corners
static Pose2 randomFreePose (double boundary_size, const std::vector< SimPolygon2D > &obstacles)
 pick a random pose in a bounded area that is not in an obstacle

Protected Attributes

Point2Vector landmarks_

Static Protected Attributes

static std::minstd_rand rng

Member Function Documentation

◆ contains()

bool gtsam::SimPolygon2D::contains ( const Point2 & p) const

Core function for randomly generating scenarios.

Polygons are closed, convex shapes.

Returns
true if the given point is contained by this polygon

◆ createRectangle()

SimPolygon2D gtsam::SimPolygon2D::createRectangle ( const Point2 & p,
double height,
double width )
static

Named constructor for creating axis-aligned rectangles.

Parameters
pis the lower-left corner

◆ overlaps()

bool gtsam::SimPolygon2D::overlaps ( const SimPolygon2D & p) const

Checks two polygons to determine if they overlap.

Returns
true iff at least one vertex of one polygon is contained in the other

The documentation for this class was generated from the following files: