polygon.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #ifndef POLYGON_H_
31 #define POLYGON_H_
32 
33 #include <sstream>
34 
35 #ifndef DEG_TO_RAD
36 #define DEG_TO_RAD 0.0174532925
37 #endif
38 
39 namespace swri_geometry_util
40 {
41  //structure for defining the vertices of a polygon
42  typedef struct
43  {
44  //vertices
45  double *x;
46  double *y;
47  }PolygonD;
48 
49  typedef struct
50  {
51  //vertex
52  double x;
53  double y;
54  }Vertex;
55 
56  class Polygon{
57  public:
58 
59  Polygon();
60  Polygon(const Polygon & other);
61  Polygon & operator= (const Polygon & other);
62 
63  Polygon(double Xs[], double Ys[], int numVertx);
64 
65  bool VertexInPolygon(Vertex vertex);
66 
67  double* GetXVerticies();
68 
69  double* GetYVerticies();
70 
71  double GetXVerticie(int num);
72 
73  double GetYVerticie(int num);
74 
75  int GetNumVerticies();
76 
77  bool LineOverlapsPolygon(Vertex start, Vertex end);
78 
79  ~Polygon();
80 
81  private:
82 
83  Vertex FindLineIntersectLine(Vertex start1, Vertex end1, Vertex start2,
84  Vertex end2);
85 
86  PolygonD _shape; //list of polygon vertices
87  int _nvert; //number of vertices in this polygon
88  };
89 } // end namespace swri_geometry_util
90 #endif /* POLYGON_H_ */
double GetXVerticie(int num)
Definition: polygon.cpp:190
bool VertexInPolygon(Vertex vertex)
Definition: polygon.cpp:95
double GetYVerticie(int num)
Definition: polygon.cpp:196
Polygon & operator=(const Polygon &other)
Definition: polygon.cpp:55
Vertex FindLineIntersectLine(Vertex start1, Vertex end1, Vertex start2, Vertex end2)
Definition: polygon.cpp:142
bool LineOverlapsPolygon(Vertex start, Vertex end)
Definition: polygon.cpp:111


swri_geometry_util
Author(s): Marc Alban
autogenerated on Tue Apr 6 2021 02:50:29