LARS
LARS (Light Augmented Reality System) is an open-source framework for light-based interaction and real-time tracking in multi-robot experiments. Inspired by ARK, LARS extends the augmented reality paradigm to robotic collectives by projecting dynamic visual cues and environments onto the arena, enabling new experimental possibilities for collective robotics research, education, and outreach. LARS features integrated tracking, light projection, and modular experiment control with a user-friendly Qt GUI.
Loading...
Searching...
No Matches
convex_hull.h
Go to the documentation of this file.
1// -*-c++-*-
2
7
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa Akiyama
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
30#ifndef RCSC_GEOM_CONVEX_HULL_H
31#define RCSC_GEOM_CONVEX_HULL_H
32
33#include "geom/vector_2d.h"
34#include "geom/segment_2d.h"
35#include "geom/polygon_2d.h"
36
37#include <vector>
38#include <set>
39
40namespace rcsc {
41
42class ConvexHull {
43public:
44 typedef std::vector< Vector2D > PointCont;
45 typedef std::vector< Vector2D > VertexCont;
46 typedef std::vector< Segment2D > EdgeCont;
47
53 DirectMethod,
54 WrappingMethod,
55 GrahamScan,
56 // IncrementalMethod,
57 // DivideConquer,
58 // QuickMethod,
59 // InnerPointsElimination,
60 };
61
62private:
63
64 PointCont M_input_points;
65
66 VertexCont M_vertices;
67 EdgeCont M_edges;
68
69
70 // not used
71 ConvexHull( const ConvexHull & );
72 ConvexHull & operator=( const ConvexHull & );
73
74public:
75
79 ConvexHull();
80
85 ConvexHull( const PointCont & v );
86
90 void clear();
91
95 void clearResults();
96
101 void addPoint( const Vector2D & p )
102 {
103 M_input_points.push_back( p );
104 }
105
110 void addPoints( const PointCont & v )
111 {
112 M_input_points.insert( M_input_points.end(), v.begin(), v.end() );
113 }
114
118 // void compute();
119
124 void compute( const MethodType type = WrappingMethod );
125
130 const PointCont & inputPoints() const
131 {
132 return M_input_points;
133 }
134
139 const VertexCont & vertices() const
140 {
141 return M_vertices;
142 }
143
148 const EdgeCont & edges() const
149 {
150 return M_edges;
151 }
152
153private:
154
158 void computeDirectMethod();
159
163 void computeWrappingMethod();
164
168 void computeGrahamScan();
169
173 // void computeIncrementalMethod();
174
178 // void computeDivideAndConquer();
179
183 // void computeQuickMethod();
184
188 // void computeInnerPointsElimination();
189
190private:
191
195 size_t getMinPointIndex() const;
196
197 void sortPointsByAngleFrom( const size_t index );
198
199public:
200
205 Polygon2D toPolygon() const;
206
212 std::ostream & printInputPoints( std::ostream & os ) const;
213
219 std::ostream & printVertices( std::ostream & os ) const;
220
226 std::ostream & printEdges( std::ostream & os ) const;
227
228};
229
230}
231
232#endif
Definition convex_hull.h:42
std::ostream & printInputPoints(std::ostream &os) const
output input points to the stream in gnuplot format.
Definition convex_hull.cpp:541
ConvexHull()
create empty convex hull
Definition convex_hull.cpp:94
void clearResults()
clear result variables.
Definition convex_hull.cpp:126
MethodType
algoritym type
Definition convex_hull.h:52
std::ostream & printEdges(std::ostream &os) const
output edges to the stream in gnuplot format.
Definition convex_hull.cpp:583
std::vector< Vector2D > PointCont
input point container
Definition convex_hull.h:44
Polygon2D toPolygon() const
get the convex hull polygon
Definition convex_hull.cpp:531
void addPoint(const Vector2D &p)
add a new point to the set of input point
Definition convex_hull.h:101
const PointCont & inputPoints() const
get the reference to the input point container
Definition convex_hull.h:130
const VertexCont & vertices() const
get the reference to the vertex container ordered by counter clockwise
Definition convex_hull.h:139
void clear()
clear all data.
Definition convex_hull.cpp:115
std::vector< Vector2D > VertexCont
result vertex container
Definition convex_hull.h:45
std::ostream & printVertices(std::ostream &os) const
output vertices to the stream in gnuplot format.
Definition convex_hull.cpp:565
void addPoints(const PointCont &v)
add new points to the set of input pointc
Definition convex_hull.h:110
void compute(const MethodType type=WrappingMethod)
generate convex hull by default method.
Definition convex_hull.cpp:149
std::vector< Segment2D > EdgeCont
result edge container
Definition convex_hull.h:46
const EdgeCont & edges() const
get the reference to the result edge container
Definition convex_hull.h:148
2D polygon region class
Definition polygon_2d.h:47
2D point vector class
Definition vector_2d.h:47
2d vector class Header File.
2D polygon region Header File.
2D segment line Header File.