ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
larcfm::Poly2D Class Reference

#include <Poly2D.h>

Public Member Functions

 Poly2D (const std::vector< Vect2 > &verts)
 
 Poly2D (const Poly2D &polygon)
 
int size () const
 
Poly2D linear (const Vect2 &v, double t) const
 
Poly2D linear (const std::vector< Vect2 > &v, double t) const
 
void add (double x, double y)
 
void add (const Vect2 &v)
 
void insert (int i, const Vect2 &v)
 
Vect2 get (int i) const
 
void set (int i, const Vect2 &v)
 
void remove (int n)
 
bool contains (double a, double b) const
 
bool contains (const Vect2 &v) const
 
std::vector< Vect2getVerticesRef () const
 
double signedArea () const
 
double area () const
 
Vect2 centroid () const
 
Vect2 averagePoint () const
 
double innerDiameter () const
 
double outerDiameter () const
 
bool isClockwise () const
 
Poly2D reverseOrder () const
 
double apBoundingRadius () const
 
void recalcBoundingRectangle ()
 
std::string strVectArray (const std::vector< Vect2 > &verts) const
 
std::string toString () const
 

Private Attributes

std::vector< Vect2vertices
 
double minX
 
double minY
 
double maxX
 
double maxY
 

Static Private Attributes

static const double vertexPerturb = 1E-10
 
static const double perturbAmount = 2E-10
 

Detailed Description

Encapsulates a geometric polygon. The polygon is defined in terms of its vertex coordinates. This implementation assumes a simply connected polygon. The Polygon is otherwise quite general allowing multiply connected regions. The class provides a containment test for points and uses bounding rectangles to speed up computations.

Note: It does not use the "BoundingRectangle" class to avoid importing Lat/Lon classes such as GreatCircle.

Constructor & Destructor Documentation

◆ Poly2D()

larcfm::Poly2D::Poly2D ( const Poly2D polygon)

Constructor for creating a copy of a Polygon

Parameters
polygonThe polygon to be copied

Member Function Documentation

◆ apBoundingRadius()

double larcfm::Poly2D::apBoundingRadius ( ) const

Distance from averagePoint to farthest vertex

Returns
radius

◆ area()

double larcfm::Poly2D::area ( ) const

Return the horizontal area (in m^2) of this Poly3D.

Returns
area

Return the horizontal area (in m^2) of this Poly3D.

◆ averagePoint()

Vect2 larcfm::Poly2D::averagePoint ( ) const

Return the average of all vertices. Note this is not the same as the centroid, and will be weighted towards concentrations of vertices instead of concentrations of area/mass. This will, however, have the nice property of having a constant linear velocity between two polygons, even if they morph shape.

Returns
point

◆ centroid()

Vect2 larcfm::Poly2D::centroid ( ) const
Returns
the geometric centroid.

◆ contains()

bool larcfm::Poly2D::contains ( double  a,
double  b 
) const

Determines if the supplied point lies within this polygon. Uses the "crossing number" algorithm This uses a standard raycasting check for point inclusion. It does not explicitly use ACCoRD detection algorithms.

Parameters
a- x coordinate of the point
b- y coordinate of the point
Returns
true if the Polygon contains the point (a, b), otherwise false

◆ get()

Vect2 larcfm::Poly2D::get ( int  i) const

Return vertex, or INVALID if out of bounds.

Parameters
iindex
Returns
vertex

◆ innerDiameter()

double larcfm::Poly2D::innerDiameter ( ) const

Return the horizontal area (in m^2) of this Poly3D.

◆ remove()

void larcfm::Poly2D::remove ( int  n)

Remove a point from this SimplePolyNew.

Parameters
nIndex (in order added) of the point to be removed.

◆ reverseOrder()

Poly2D larcfm::Poly2D::reverseOrder ( ) const

Reverse order of vertices

Returns
polygon

◆ set()

void larcfm::Poly2D::set ( int  i,
const Vect2 v 
)

Determines if the supplied point lies within this polygon. Uses the "crossing number" algorithm This uses a standard raycasting check for point inclusion. It does not explicitly use ACCoRD detection algorithms.

Parameters
iindex
vvector

◆ signedArea()

double larcfm::Poly2D::signedArea ( ) const

Planar geometric area of a simple polygon. It is positive if the vertices are ordered counterclockwise and negative if clockwise.

Returns
the signed area of the polygon

◆ strVectArray()

std::string larcfm::Poly2D::strVectArray ( const std::vector< Vect2 > &  verts) const

Returns a GeneralPath representation for testing purposes.

Returns
this polygon as a GeneralPath

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