se2ez
polygon.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef SE2EZ_CORE_CGAL_POLYGON_
4 #define SE2EZ_CORE_CGAL_POLYGON_
5 
6 #include <Eigen/Core>
7 #include <Eigen/Geometry>
8 
10 #include <se2ez/core/math.h>
11 
12 namespace se2ez
13 {
14  /** \cond IGNORE */
15  SE2EZ_CLASS_FORWARD(Geometry)
16  /** \endcond */
17 
18  /** \brief Operations on geometry.
19  */
20  namespace geo
21  {
22  /** \brief Checks if a polygon is convex.
23  * \param[in] geometry Geometry to check (must be a polygon)
24  * \return Returns true if the polygon is convex, false otherwise.
25  */
26  bool isConvex(const Geometry &geometry);
27 
28  /** \brief Checks if a polygon is simple, that is, it has no holes.
29  * \param[in] geometry Geometry to check (must be a polygon)
30  * \return Returns true if the polygon is simple.
31  */
32  bool isSimple(const Geometry &geometry);
33 
34  /** \brief If not clockwise, reorders polygon vertices to be in clockwise orientation.
35  * \param[in,out] geometry Geometry to reorder.
36  */
37  void makeClockwise(Geometry &geometry);
38 
39  /** \brief If not counterclockwise, reorders polygon vertices to be in counterclockwise orientation.
40  * \param[in,out] geometry Geometry to reorder.
41  */
42  void makeCounterClockwise(Geometry &geometry);
43 
44  /** \brief Compute the area of a polygon.
45  * \param[in] geometry Geometry to compute area for.
46  * \return The signed area of the polygon (negative if clockwise, positive if counter).
47  */
48  double area(const Geometry &geometry);
49 
50  /** \brief Performs an approximate convex decomposition on the geometry.
51  * \param[in] geometry Geometry to decompose.
52  * \return A vector of the convex partitions of the original geometry.
53  */
55 
56  /** \brief Performs an optimal convex decomposition on the geometry.
57  * \param[in] geometry Geometry to decompose.
58  * \return A vector of the convex partitions of the original geometry.
59  */
61 
62  /** \brief "Shatters" a convex polygon into a fan of triangles using the first point as the root for
63  all triangles.
64  * \param[in] geometry Geometry to shatter.
65  * \return A vector of triangle polygons from the original geometry.
66  */
68  } // namespace geo
69 } // namespace se2ez
70 
71 #endif
void makeClockwise(Geometry &geometry)
If not clockwise, reorders polygon vertices to be in clockwise orientation.
Definition: polygon.cpp:82
double area(const Geometry &geometry)
Compute the area of a polygon.
Definition: polygon.cpp:106
bool isSimple(const Geometry &geometry)
Checks if a polygon is simple, that is, it has no holes.
Definition: polygon.cpp:75
std::vector< GeometryPtr > shatter(const GeometryPtr &geometry)
"Shatters" a convex polygon into a fan of triangles using the first point as the root for all triangl...
Definition: polygon.cpp:167
A shared pointer wrapper for se2ez::Geometry.
std::vector< GeometryPtr > convexifyApproximate(const GeometryPtr &geometry)
Performs an approximate convex decomposition on the geometry.
Definition: polygon.cpp:113
void makeCounterClockwise(Geometry &geometry)
If not counterclockwise, reorders polygon vertices to be in counterclockwise orientation.
Definition: polygon.cpp:94
std::vector< GeometryPtr > convexifyOptimal(const GeometryPtr &geometry)
Performs an optimal convex decomposition on the geometry.
Definition: polygon.cpp:141
bool isConvex(const Geometry &geometry)
Checks if a polygon is convex.
Definition: polygon.cpp:68
Main namespace.
Definition: collision.h:11
#define SE2EZ_CLASS_FORWARD(C)
Definition: class_forward.h:9