ICAROUS
|
#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< Position > | getVertices () 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< LatLonAlt > | rip (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 |
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!
larcfm::SimplePoly::SimplePoly | ( | ) |
Constructs an empty SimplePoly.
larcfm::SimplePoly::SimplePoly | ( | double | b, |
double | t | ||
) |
Constructor for a SimplePoly with predefined top and bottom altitudes.
b | Bottom altitude [m] |
t | Top altitude [m] |
Constructor for a SimplePoly with predefined top and bottom altitudes.
b | Bottom altitude |
t | Top altitude |
larcfm::SimplePoly::SimplePoly | ( | double | b, |
double | t, | ||
const std::string & | units | ||
) |
Constructor for a SimplePoly with predefined top and bottom altitudes.
b | Bottom altitude |
t | Top altitude |
units | units to interpret both altitudes |
larcfm::SimplePoly::SimplePoly | ( | const SimplePoly & | p | ) |
Create a deep copy of a SimplePoly
p | Source poly. |
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)
p | position to add |
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)
p | position to add |
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
p | position to add |
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)
p | position to add |
double larcfm::SimplePoly::area | ( | ) |
Area in square meters.
Area in square meters.
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.
Position larcfm::SimplePoly::boundingCircleCenter | ( | ) |
Returns the center of a circle completely containing this SimplePoly. This is not necessarily the minimal bounding circle.
double larcfm::SimplePoly::boundingCircleRadius | ( | ) |
Returns the radius of a circle completely containing this SimplePoly. This is not necessarily the minimal bounding circle.
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
bool larcfm::SimplePoly::contains | ( | const Position & | p | ) |
This uses a standard raycasting check for point inclusion. It does not explicitly use ACCoRD detection algorithms.
p | position |
bool larcfm::SimplePoly::contains2D | ( | const Position & | p | ) |
This uses a standard raycasting check for point inclusion. It does not explicitly use ACCoRD detection algorithms.
p | position |
SimplePoly larcfm::SimplePoly::copy | ( | ) | const |
Returns a deep copy of this SimplPoly.
double larcfm::SimplePoly::distanceFromEdge | ( | const Position & | p | ) | const |
closest horizontal distance from p to an edge.
p | position |
closest horizontal distance from p to an edge.
p |
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.
p | position |
return vertical distance from the polygon. This will be zero if the point is between the polygon's top and bottom.
p |
double larcfm::SimplePoly::getBottom | ( | ) | const |
Return the bottom altitude of this SimplePoly.
double larcfm::SimplePoly::getTop | ( | ) | const |
Return the top altitude of this SimplePoly.
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.
n | index |
Returns the position of the top point with index n. If n is not a valid index, this returns INVALID // the centroid position.
n | index |
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.
n | index |
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.
n | index |
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.
sz | desired 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.
sp1 | Polygon |
sz | desired number of vertices |
bool larcfm::SimplePoly::isConvex | ( | ) | const |
Returns true if this polygon is convex
bool larcfm::SimplePoly::isLatLon | ( | ) | const |
Determine if the polygon contains geodetic points.
SimplePoly larcfm::SimplePoly::linearFixedShape | ( | const Velocity & | v, |
double | t | ||
) | const |
Move a polygon by velocity using vertex 0 and reconstructing geometrically
v | velocity |
t | time |
Move a polygon by velocity using vertex 0 and reconstructing geometrically
v | |
t |
|
static |
Create a SimplePoly from a Poly3D. This SimplePoly will use Euclidean coordinates.
p3 | 3D polygon |
|
static |
Create a SimplePoly from a Poly3D. This SimplePoly will use latlon coordinates .
p3 | 3D polygon |
proj | projection to use to interpret the points in the 3D polygon |
|
static |
Create a SimplePoly from a Poly3D. This SimplePoly will use Euclidean coordinates.
p3 | 3D polygon |
|
static |
Create a SimplePoly from a List<LatLonAlt>.
pList | list of points |
b | bottom altitude |
t | top altitude |
Create a SimplePoly from a std::vector<LatLonAlt>.
double larcfm::SimplePoly::maxRadius | ( | ) |
Returns the max horizontal distance between any vertex and the centroid
|
static |
Create a SimplePoly from a List<Position>.
pList | list of points |
b | bottom altitude |
t | top altitude |
Create a SimplePoly from a std::vector<Position>.
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.
i | index |
Poly3D larcfm::SimplePoly::poly3D | ( | const EuclideanProjection & | proj | ) |
return a Poly3D version of this. proj is ignored if this is Euclidean
proj | projection |
Poly3D larcfm::SimplePoly::poly3D | ( | const EuclideanProjection & | proj | ) | const |
return a Poly3D version of this. proj is ignored if this is Euclidean
proj | projection |
return a aPolygon3D version of this
void larcfm::SimplePoly::remove | ( | int | n | ) |
Remove a point from this SimplePoly.
n | Index (in order added) of the point to be removed. |
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.
n | index |
p | position |
void larcfm::SimplePoly::setBottom | ( | double | b | ) |
Sets the bottom altitude of this SimplePoly.
b | New bottom altitude. |
void larcfm::SimplePoly::setTop | ( | double | t | ) |
Sets the top altitude of this SimplePoly.
t | New top altitude. |
|
private |
Return the area (in m^2 or rad^2) of this SimplePoly.
int larcfm::SimplePoly::size | ( | ) | const |
Number of points
string larcfm::SimplePoly::toString | ( | ) | const |
String representation of this SimplePoly.
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.
off | offset |
This moves the SimplePoly by the amount determined by the given (Euclidean) offset.
off | offset |
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.
i | index |