ICAROUS
|
#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< Vect2 > | getVerticesRef () 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< Vect2 > | vertices |
double | minX |
double | minY |
double | maxX |
double | maxY |
Static Private Attributes | |
static const double | vertexPerturb = 1E-10 |
static const double | perturbAmount = 2E-10 |
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.
larcfm::Poly2D::Poly2D | ( | const Poly2D & | polygon | ) |
Constructor for creating a copy of a Polygon
polygon | The polygon to be copied |
double larcfm::Poly2D::apBoundingRadius | ( | ) | const |
Distance from averagePoint to farthest vertex
double larcfm::Poly2D::area | ( | ) | const |
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.
Vect2 larcfm::Poly2D::centroid | ( | ) | const |
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.
a | - x coordinate of the point |
b | - y coordinate of the point |
Vect2 larcfm::Poly2D::get | ( | int | i | ) | const |
Return vertex, or INVALID if out of bounds.
i | index |
double larcfm::Poly2D::innerDiameter | ( | ) | const |
Return the horizontal area (in m^2) of this Poly3D.
void larcfm::Poly2D::remove | ( | int | n | ) |
Remove a point from this SimplePolyNew.
n | Index (in order added) of the point to be removed. |
Poly2D larcfm::Poly2D::reverseOrder | ( | ) | const |
Reverse order of vertices
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.
i | index |
v | vector |
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.
std::string larcfm::Poly2D::strVectArray | ( | const std::vector< Vect2 > & | verts | ) | const |
Returns a GeneralPath representation for testing purposes.