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

#include <SimplePoly.h>

Public Member Functions

 SimplePoly ()
 
 SimplePoly (double b, double t)
 
 SimplePoly (double b, double t, const std::string &units)
 
 SimplePoly (const SimplePoly &p)
 
bool equals (const SimplePoly &p) const
 
Position getVertex (int n) const
 
std::vector< PositiongetVertices () const
 
Poly3D poly3D (const EuclideanProjection &proj) const
 
bool isLatLon () const
 
bool isClockwise () const
 
void reverseOrder ()
 
double distanceFromEdge (const Position &p) const
 
double distanceV (const Position &p) const
 
bool contains (const Position &p)
 
bool contains2D (const Position &p)
 
int size () const
 
void increaseVertices (int sz)
 
Position centroid ()
 
double area ()
 
Position averagePoint ()
 
double apBoundingRadius ()
 
Position boundingCircleCenter ()
 
bool isConvex () const
 
double boundingCircleRadius ()
 
Position maxDistPair (const Position &p) const
 
double maxRadius ()
 
bool insert (int i, const Position &p)
 
bool add (const Position &p)
 
bool add (const LatLonAlt &p)
 
bool add (const Vect2 &p)
 
void remove (int n)
 
bool set (int n, Position p)
 
void setTop (double t)
 
double getTop () const
 
void setBottom (double b)
 
double getBottom () const
 
Position getTopPoint (int n) const
 
SimplePoly copy () const
 
Poly3D poly3D (const EuclideanProjection &proj)
 
void translate (const Vect3 &off)
 
SimplePoly linear (const Velocity &v, double t) const
 
SimplePoly linearAllVerts (const Velocity &v, double t) const
 
SimplePoly linearFixedShape (const Velocity &v, double t) const
 
bool validate () const
 
bool validate (ErrorLog *error) const
 
int maxInRange (const Position &p, double a1, double a2) const
 
BoundingRectangle getBoundingRectangle ()
 
double perpSide (int i) const
 
double vertexAngle (int i)
 
std::string toOutput (const std::string &name, int precision, int numberTcpColumns) const
 
std::string toString () const
 
std::vector< std::string > toStringList (int vertex, int precision) const
 

Static Public Member Functions

static SimplePoly make (const Poly3D &p3)
 
static SimplePoly make (const Poly3DLL &p3)
 
static SimplePoly make (const Poly3D &p3, const EuclideanProjection &proj)
 
static SimplePoly make (std::vector< LatLonAlt > pList, double b, double t)
 
static SimplePoly mk (std::vector< Position > pList, double b, double t)
 
static std::vector< LatLonAltrip (const SimplePoly &sPoly)
 

Private Member Functions

void init ()
 
void calcCentroid () const
 
double signedArea (double dx, double dy) const
 
Position avgPos (const std::vector< Position > &points, const std::vector< double > &wgts)
 
bool vertexConvex (const Position &p0, const Position &p1, const Position &p2)
 

Private Attributes

bool isLatLon_b
 
Poly3D p3d
 
Poly3DLL p3dll
 
bool centroidDefined
 
bool averagePointDefined
 
Position cPos
 
Position aPos
 
double clockwiseSum
 

Static Private Attributes

static const bool move_constant_shape = false
 

Detailed Description

A basic polygon that describes a volume. This volume has a flat bottom and top (specified as altitude values). Points describe the cross-section area vertices in a consistently clockwise (or consistently counter-clockwise) manner. The cross-section need not be convex, but an "out of order" listing of the vertices will result in edges that cross, and will cause several calculations to fail (with no warning).

A SimplePoly sets the altitude for all its points to be the bottom altitude, while the top is stored elsewhere as a single value. The exact position for "top" vertices is computed on demand.

The cross-section must be a simple polygon, that is it allows for non-convex areas, but vertices and edges may not overlap or cross. Vertices may be ordered in either a clockwise or counterclockwise manner.

(A vertex-complete polygon allows for vertices and edges to overlap but not cross, while a general polygon allows for edges to cross.)

Point indices are based on the order they are added.

Note: polygon support is experimental and the interface is subject to change!

Constructor & Destructor Documentation

◆ SimplePoly() [1/4]

larcfm::SimplePoly::SimplePoly ( )

Constructs an empty SimplePoly.

◆ SimplePoly() [2/4]

larcfm::SimplePoly::SimplePoly ( double  b,
double  t 
)

Constructor for a SimplePoly with predefined top and bottom altitudes.

Parameters
bBottom altitude [m]
tTop altitude [m]

Constructor for a SimplePoly with predefined top and bottom altitudes.

Parameters
bBottom altitude
tTop altitude

◆ SimplePoly() [3/4]

larcfm::SimplePoly::SimplePoly ( double  b,
double  t,
const std::string &  units 
)

Constructor for a SimplePoly with predefined top and bottom altitudes.

Parameters
bBottom altitude
tTop altitude
unitsunits to interpret both altitudes

◆ SimplePoly() [4/4]

larcfm::SimplePoly::SimplePoly ( const SimplePoly p)

Create a deep copy of a SimplePoly

Parameters
pSource poly.

Member Function Documentation

◆ add() [1/3]

bool larcfm::SimplePoly::add ( const LatLonAlt lla)

Add a new point to the SimplePoly. Points should be added in a consistently clockwise or consistently counter-clockwise manner. This currently does NOT set the Z component of the point (unless it is the first point)

Parameters
pposition to add
Returns
false, if an error is detected (duplicate or invalid vertex), true otherwise.

◆ add() [2/3]

bool larcfm::SimplePoly::add ( const Position p)

Add a new point to the SimplePoly. Points should be added in a consistently clockwise or consistently counter-clockwise manner. This currently does NOT set the Z component of the point (unless it is the first point)

Parameters
pposition to add
Returns
false, if an error is detected (duplicate or invalid vertex), true otherwise.

Add a new vertex to the SimplePoly. Points should be added in a consistently clockwise or consistently counter-clockwise manner. This currently does NOT set the Z component of the point

Parameters
pposition to add
Returns
false, if an error is detected (duplicate or invalid vertex), true otherwise.

◆ add() [3/3]

bool larcfm::SimplePoly::add ( const Vect2 v)

Add a new point to the SimplePoly. Points should be added in a consistently clockwise or consistently counter-clockwise manner. This currently does NOT set the Z component of the point (unless it is the first point)

Parameters
pposition to add
Returns
false, if an error is detected (duplicate or invalid vertex), true otherwise.

◆ area()

double larcfm::SimplePoly::area ( )

Area in square meters.

Returns
area

Area in square meters.

◆ averagePoint()

Position larcfm::SimplePoly::averagePoint ( )

Return the average of all vertices. Note this is not the same as the centroid! This will, however, have the nice property of having a constant velocity when dealing with a morphing polygon.

Returns
average of all vertices

◆ boundingCircleCenter()

Position larcfm::SimplePoly::boundingCircleCenter ( )

Returns the center of a circle completely containing this SimplePoly. This is not necessarily the minimal bounding circle.

Returns
center of polygon

◆ boundingCircleRadius()

double larcfm::SimplePoly::boundingCircleRadius ( )

Returns the radius of a circle completely containing this SimplePoly. This is not necessarily the minimal bounding circle.

Returns
radius of bounding circle

◆ centroid()

Position larcfm::SimplePoly::centroid ( )

Return this centroid of this volume. Note: if sides are small (less than about 10^-5 in internal units), there may be errors in the centroid calculations

Returns
The centroid position of this volume.

◆ contains()

bool larcfm::SimplePoly::contains ( const Position p)

This uses a standard raycasting check for point inclusion. It does not explicitly use ACCoRD detection algorithms.

Parameters
pposition
Returns
true, if position is in the polygon

◆ contains2D()

bool larcfm::SimplePoly::contains2D ( const Position p)

This uses a standard raycasting check for point inclusion. It does not explicitly use ACCoRD detection algorithms.

Parameters
pposition
Returns
true, if position is in the polygon

◆ copy()

SimplePoly larcfm::SimplePoly::copy ( ) const

Returns a deep copy of this SimplPoly.

Returns
copy

◆ distanceFromEdge()

double larcfm::SimplePoly::distanceFromEdge ( const Position p) const

closest horizontal distance from p to an edge.

Parameters
pposition
Returns
distance from edge

closest horizontal distance from p to an edge.

Parameters
p
Returns
distance from edge

◆ distanceV()

double larcfm::SimplePoly::distanceV ( const Position p) const

return vertical distance from the polygon. This will be zero if the point is between the polygon's top and bottom.

Parameters
pposition
Returns
distance

return vertical distance from the polygon. This will be zero if the point is between the polygon's top and bottom.

Parameters
p
Returns

◆ getBottom()

double larcfm::SimplePoly::getBottom ( ) const

Return the bottom altitude of this SimplePoly.

Returns
bottom altitude

◆ getTop()

double larcfm::SimplePoly::getTop ( ) const

Return the top altitude of this SimplePoly.

Returns
top altitude

◆ getTopPoint()

Position larcfm::SimplePoly::getTopPoint ( int  n) const

Returns the position of the top point with index n. If n is not a valid index, this returns the centroid position.

Parameters
nindex
Returns
position

Returns the position of the top point with index n. If n is not a valid index, this returns INVALID // the centroid position.

Parameters
nindex
Returns
position

◆ getVertex()

Position larcfm::SimplePoly::getVertex ( int  n) const

Returns the position of the (bottom) point with index n. This returns an INVALID point if the index is invalid, not the centroid.

NOTE: The altitude component of the nth position is ambiguous. This method returns the bottom altitude of the 3D object.

Parameters
nindex
Returns
position

Returns the position of the (bottom) point with index n. If n is not a valid index, this returns the centroid position. // TODO: Huh?

NOTE: The altitude component of the nth position is ambiguous. This method returns the bottom altitude of the 3D object.

Parameters
nindex
Returns
position

◆ increaseVertices()

void larcfm::SimplePoly::increaseVertices ( int  sz)

Add vertices to a polygon until it has a specified number. This will not remove vertices if there are already more than the desired number.
Each new vertex will be added the to current longest edge.

Parameters
szdesired number of vertices

Add vertices to a polygon until it has a specified number. This will not remove vertices if there are already more than the desired number. Each new vertex will be added the to current longest edge.

Parameters
sp1Polygon
szdesired number of vertices

◆ isConvex()

bool larcfm::SimplePoly::isConvex ( ) const

Returns true if this polygon is convex

Returns
true, if convex

◆ isLatLon()

bool larcfm::SimplePoly::isLatLon ( ) const

Determine if the polygon contains geodetic points.

Returns
True if this SimplePoly contains any geodetic points. If size is 0, returns false.

◆ linearFixedShape()

SimplePoly larcfm::SimplePoly::linearFixedShape ( const Velocity v,
double  t 
) const

Move a polygon by velocity using vertex 0 and reconstructing geometrically

Parameters
vvelocity
ttime
Returns
polygon

Move a polygon by velocity using vertex 0 and reconstructing geometrically

Parameters
v
t
Returns

◆ make() [1/4]

SimplePoly larcfm::SimplePoly::make ( const Poly3D p3)
static

Create a SimplePoly from a Poly3D. This SimplePoly will use Euclidean coordinates.

Parameters
p33D polygon
Returns
a new SimplePoly

◆ make() [2/4]

SimplePoly larcfm::SimplePoly::make ( const Poly3D p3,
const EuclideanProjection &  proj 
)
static

Create a SimplePoly from a Poly3D. This SimplePoly will use latlon coordinates .

Parameters
p33D polygon
projprojection to use to interpret the points in the 3D polygon
Returns
a new SimplePoly

◆ make() [3/4]

SimplePoly larcfm::SimplePoly::make ( const Poly3DLL p3)
static

Create a SimplePoly from a Poly3D. This SimplePoly will use Euclidean coordinates.

Parameters
p33D polygon
Returns
a new SimplePoly

◆ make() [4/4]

SimplePoly larcfm::SimplePoly::make ( std::vector< LatLonAlt pList,
double  b,
double  t 
)
static

Create a SimplePoly from a List<LatLonAlt>.

Parameters
pListlist of points
bbottom altitude
ttop altitude
Returns
a new SimplePoly

Create a SimplePoly from a std::vector<LatLonAlt>.

Returns
a new SimplePoly

◆ maxRadius()

double larcfm::SimplePoly::maxRadius ( )

Returns the max horizontal distance between any vertex and the centroid

Returns
radius

◆ mk()

SimplePoly larcfm::SimplePoly::mk ( std::vector< Position pList,
double  b,
double  t 
)
static

Create a SimplePoly from a List<Position>.

Parameters
pListlist of points
bbottom altitude
ttop altitude
Returns
a new SimplePoly

Create a SimplePoly from a std::vector<Position>.

Returns
a new SimplePoly

◆ perpSide()

double larcfm::SimplePoly::perpSide ( int  i) const

Return the angle that is perpendicular to the middle of the edge from vertex i to i+1, facing outward. Return NaN if i is out of bounds or vertex i overlaps vertex i+1.

Parameters
iindex
Returns
angle

◆ poly3D() [1/2]

Poly3D larcfm::SimplePoly::poly3D ( const EuclideanProjection &  proj)

return a Poly3D version of this. proj is ignored if this is Euclidean

Parameters
projprojection
Returns
a new 3D polygon

◆ poly3D() [2/2]

Poly3D larcfm::SimplePoly::poly3D ( const EuclideanProjection &  proj) const

return a Poly3D version of this. proj is ignored if this is Euclidean

Parameters
projprojection
Returns
a new 3D polygon

return a aPolygon3D version of this

◆ remove()

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

Remove a point from this SimplePoly.

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

◆ set()

bool larcfm::SimplePoly::set ( int  n,
Position  p 
)

Change the position of a point already added to the SimplePoly, indicated by its index. This currently does NOT set the Z component of the point.

Parameters
nindex
pposition
Returns
false, if an invalid vertex is detected, true otherwise

◆ setBottom()

void larcfm::SimplePoly::setBottom ( double  b)

Sets the bottom altitude of this SimplePoly.

Parameters
bNew bottom altitude.

◆ setTop()

void larcfm::SimplePoly::setTop ( double  t)

Sets the top altitude of this SimplePoly.

Parameters
tNew top altitude.

◆ signedArea()

double larcfm::SimplePoly::signedArea ( double  dx,
double  dy 
) const
private

Return the area (in m^2 or rad^2) of this SimplePoly.

◆ size()

int larcfm::SimplePoly::size ( ) const

Number of points

Returns
Number of points in this SimplePoly

◆ toString()

string larcfm::SimplePoly::toString ( ) const

String representation of this SimplePoly.

◆ translate()

void larcfm::SimplePoly::translate ( const Vect3 off)

This moves the SimplePoly by the amount determined by the given (Euclidean) offset. Used in GUI for dragging things.

Parameters
offoffset

This moves the SimplePoly by the amount determined by the given (Euclidean) offset.

Parameters
offoffset

◆ vertexAngle()

double larcfm::SimplePoly::vertexAngle ( int  i)

Return the internal angle of vertex i. Return NaN if i is out of bounds or vertex i overlaps with an adjacent vertex.

Parameters
iindex
Returns
angle

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