include
swri_geometry_util
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_ */
swri_geometry_util::Polygon::GetYVerticies
double * GetYVerticies()
Definition:
polygon.cpp:184
swri_geometry_util::Polygon::~Polygon
~Polygon()
Definition:
polygon.cpp:207
swri_geometry_util::Polygon::GetNumVerticies
int GetNumVerticies()
Definition:
polygon.cpp:201
swri_geometry_util::Polygon::GetXVerticie
double GetXVerticie(int num)
Definition:
polygon.cpp:190
swri_geometry_util::Polygon::LineOverlapsPolygon
bool LineOverlapsPolygon(Vertex start, Vertex end)
Definition:
polygon.cpp:111
swri_geometry_util::Polygon::Polygon
Polygon()
Definition:
polygon.cpp:35
swri_geometry_util::PolygonD::x
double * x
Definition:
polygon.h:45
swri_geometry_util::Polygon::_nvert
int _nvert
Definition:
polygon.h:87
swri_geometry_util::Polygon::operator=
Polygon & operator=(const Polygon &other)
Definition:
polygon.cpp:55
swri_geometry_util::PolygonD
Definition:
polygon.h:42
swri_geometry_util::Vertex::y
double y
Definition:
polygon.h:53
swri_geometry_util::Polygon::FindLineIntersectLine
Vertex FindLineIntersectLine(Vertex start1, Vertex end1, Vertex start2, Vertex end2)
Definition:
polygon.cpp:142
swri_geometry_util::PolygonD::y
double * y
Definition:
polygon.h:46
swri_geometry_util::Vertex::x
double x
Definition:
polygon.h:52
swri_geometry_util::Polygon::GetYVerticie
double GetYVerticie(int num)
Definition:
polygon.cpp:196
swri_geometry_util::Polygon::_shape
PolygonD _shape
Definition:
polygon.h:86
start
ROSCPP_DECL void start()
swri_geometry_util::Polygon::VertexInPolygon
bool VertexInPolygon(Vertex vertex)
Definition:
polygon.cpp:95
swri_geometry_util::Vertex
Definition:
polygon.h:49
swri_geometry_util
Definition:
cubic_spline.h:34
swri_geometry_util::Polygon
Definition:
polygon.h:56
swri_geometry_util::Polygon::GetXVerticies
double * GetXVerticies()
Definition:
polygon.cpp:178
swri_geometry_util
Author(s): Marc Alban
autogenerated on Fri Aug 2 2024 08:39:08