#include <Polygon2D.h>
|
| Polygon2D () |
|
| Polygon2D (const std::vector< std::pair< float, float > > &points) |
|
| Polygon2D (const Polygon2D &poly1, const Polygon2D &poly2) |
|
unsigned int | Size () const |
| Create Intersection Polygon. More...
|
|
const std::pair< float, float > & | Point (unsigned int p) const |
|
std::pair< float, float > | Project (const std::pair< float, float > &, float) const |
|
float | Area () const |
|
float | Perimeter () const |
|
bool | Overlap (float slope, const Polygon2D &poly2, const std::pair< float, float > &origin) const |
|
bool | PolyOverlap (const Polygon2D &poly2) const |
|
bool | PolyOverlapSegments (const Polygon2D &poly2) const |
|
bool | PointInside (const std::pair< float, float > &point) const |
|
bool | Contained (const Polygon2D &poly2) const |
|
void | UntanglePolygon () |
| check if poly2 is inside poly1 More...
|
|
Definition at line 32 of file Polygon2D.h.
Polygon2D::Polygon2D |
( |
const std::vector< std::pair< float, float > > & |
points | ) |
|
|
inline |
Definition at line 40 of file Polygon2D.h.
std::vector< std::pair< float, float > > vertices
Definition at line 52 of file Polygon2D.cxx.
57 std::vector< std::pair<float,float> > nullpoint;
69 std::vector<std::pair<float,float> > IntersectionPoints;
71 for (
unsigned int p1=0; p1 < poly1.
Size(); p1++){
75 for (
unsigned int p2=0; p2 < poly2.
Size(); p2++){
80 for (
unsigned int i=0; i < poly1.
Size(); i++){
81 for (
unsigned int j=0; j < poly2.
Size(); j++){
83 poly1.
Point(i+1).first, poly1.
Point(i+1).second,
85 poly2.
Point(j+1).first, poly2.
Point(j+1).second) )
88 poly1.
Point(i+1).first, poly1.
Point(i+1).second,
90 poly2.
Point(j+1).first, poly2.
Point(j+1).second) );
const std::pair< float, float > & Point(unsigned int p) const
unsigned int Size() const
Create Intersection Polygon.
std::vector< std::pair< float, float > > vertices
std::pair< float, float > GetIntersection(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
bool SegmentOverlap(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
bool PointInside(const std::pair< float, float > &point) const
bool PolyOverlap(const Polygon2D &poly2) const
float Polygon2D::Area |
( |
| ) |
const |
Definition at line 99 of file Polygon2D.cxx.
104 for (
unsigned int i=0; i<
vertices.size(); i++){
std::vector< std::pair< float, float > > vertices
second_as<> second
Type of time stored in seconds, in double precision.
Definition at line 274 of file Polygon2D.cxx.
279 for (
unsigned int i=0; i<poly2.
Size(); i++){
const std::pair< float, float > & Point(unsigned int p) const
unsigned int Size() const
Create Intersection Polygon.
bool PointInside(const std::pair< float, float > &point) const
bool Polygon2D::Overlap |
( |
float |
slope, |
|
|
const Polygon2D & |
poly2, |
|
|
const std::pair< float, float > & |
origin |
|
) |
| const |
Definition at line 183 of file Polygon2D.cxx.
188 float theta = tan(slope);
195 if ( ( ((range1.first <= range2.second) and ( range1.first >= range2.first )) or ((range1.second <= range2.second) and ( range1.second >= range2.first )) ) or ( ((range2.first <= range1.second) and ( range2.first >= range1.first )) or ((range2.second <= range1.second) and ( range2.second >= range1.first )) ) )
std::pair< float, float > Project(const std::pair< float, float > &, float) const
constexpr Point origin()
Returns a origin position with a point of the specified type.
float Polygon2D::Perimeter |
( |
| ) |
const |
Definition at line 116 of file Polygon2D.cxx.
119 float perimeter = 0.;
121 for (
unsigned int i=0; i<
vertices.size(); i++){
134 return sqrt(perimeter);
std::vector< std::pair< float, float > > vertices
const std::pair< float, float > & Polygon2D::Point |
( |
unsigned int |
p | ) |
const |
Definition at line 138 of file Polygon2D.cxx.
149 std::cout <<
"Out of bounds of Polygon!" <<
std::endl;
std::vector< std::pair< float, float > > vertices
QTextStream & endl(QTextStream &s)
bool Polygon2D::PointInside |
( |
const std::pair< float, float > & |
point | ) |
const |
Definition at line 252 of file Polygon2D.cxx.
258 int intersections = 0;
259 for (
unsigned int i=0; i<this->
Size(); i++){
261 this->
Point(i+1).first, this->
Point(i+1).second,
263 point.first, point.second) )
266 if ( (intersections%2) == 0 )
const std::pair< float, float > & Point(unsigned int p) const
unsigned int Size() const
Create Intersection Polygon.
bool SegmentOverlap(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
second_as<> second
Type of time stored in seconds, in double precision.
Definition at line 202 of file Polygon2D.cxx.
208 for (
unsigned int i=0; i<this->
Size(); i++){
220 for (
unsigned int i=0; i<poly2.
Size(); i++){
const std::pair< float, float > & Point(unsigned int p) const
unsigned int Size() const
Create Intersection Polygon.
bool Overlap(float slope, const Polygon2D &poly2, const std::pair< float, float > &origin) const
float FindSlope(const std::pair< float, float > &p1, const std::pair< float, float > &p2)
bool Polygon2D::PolyOverlapSegments |
( |
const Polygon2D & |
poly2 | ) |
const |
Definition at line 230 of file Polygon2D.cxx.
238 for (
unsigned int i=0; i<this->
Size(); i++){
239 for (
unsigned int j=0; j<poly2.
Size(); j++){
241 this->
Point(i+1).first, this->
Point(i+1).second,
243 poly2.
Point(j+1).first, poly2.
Point(j+1).second) ){
bool Contained(const Polygon2D &poly2) const
const std::pair< float, float > & Point(unsigned int p) const
unsigned int Size() const
Create Intersection Polygon.
bool SegmentOverlap(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
second_as<> second
Type of time stored in seconds, in double precision.
std::pair< float, float > Polygon2D::Project |
( |
const std::pair< float, float > & |
p, |
|
|
float |
theta |
|
) |
| const |
Definition at line 156 of file Polygon2D.cxx.
160 std::pair<float,float> range(10000,0);
161 std::pair<float,float> ptmp;
163 for (
unsigned int i=0; i<
vertices.size(); i++){
172 float xnew = (ptmp.first)*cos(
theta) + (ptmp.second)*sin(
theta);
174 if ( xnew < range.first )
176 if ( xnew > range.second )
std::vector< std::pair< float, float > > vertices
second_as<> second
Type of time stored in seconds, in double precision.
unsigned int Polygon2D::Size |
( |
| ) |
const |
|
inline |
Create Intersection Polygon.
Definition at line 42 of file Polygon2D.h.
std::vector< std::pair< float, float > > vertices
void Polygon2D::UntanglePolygon |
( |
| ) |
|
check if poly2 is inside poly1
Definition at line 289 of file Polygon2D.cxx.
293 for (
unsigned int i=0; i <
vertices.size()-1; i++){
297 double By =
vertices.at(i+1).second;
299 for (
unsigned int j=i+2; j <
vertices.size()-1; j++){
307 double Dy =
vertices.at(j+1).second;
std::vector< std::pair< float, float > > vertices
bool SegmentOverlap(double Ax, double Ay, double Bx, double By, double Cx, double Cy, double Dx, double Dy)
void UntanglePolygon()
check if poly2 is inside poly1
std::vector< std::pair<float,float> > Polygon2D::vertices |
|
private |
The documentation for this class was generated from the following files: