MRPT  1.9.9
TPolygon3D.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/math/TPoseOrPoint.h>
12 
13 namespace mrpt::math
14 {
15 /** 3D polygon, inheriting from std::vector<TPoint3D>
16  * \sa TPolygon2D,TSegment3D,TLine3D,TPlane,TPoint3D
17  */
18 class TPolygon3D : public std::vector<TPoint3D>
19 {
20  public:
21  /** Distance to point (always >=0) */
22  double distance(const TPoint3D& point) const;
23  /** Check whether a point is inside (or within geometryEpsilon of a polygon
24  * edge). This works for concave or convex polygons. */
25  bool contains(const TPoint3D& point) const;
26  /** Gets as set of segments, instead of set of points. */
27  void getAsSegmentList(std::vector<TSegment3D>& v) const;
28  /** Gets a plane which contains the polygon. Returns false if the polygon is
29  * skew and cannot be fit inside a plane. */
30  bool getPlane(TPlane& p) const;
31  /** Gets the best fitting plane, disregarding whether the polygon actually
32  * fits inside or not. \sa getBestFittingPlane */
33  void getBestFittingPlane(TPlane& p) const;
34  /** Projects into a 2D space, discarding the z. \sa getPlane,isSkew */
35  void generate2DObject(TPolygon2D& p) const;
36  /** Get polygon's central point. */
37  void getCenter(TPoint3D& p) const;
38  /** Check whether the polygon is skew. Returns true if there doesn't exist a
39  * plane in which the polygon can fit. \sa getBestFittingPlane */
40  bool isSkew() const;
41  /** Remove polygon's repeated vertices. */
43  /** Erase every redundant vertex, thus saving space. */
45  /** Default constructor. Creates a polygon with no vertices. */
46  TPolygon3D() : std::vector<TPoint3D>() {}
47  /** Constructor for a given size. Creates a polygon with a fixed number of
48  * vertices, which are initialized to garbage. */
49  explicit TPolygon3D(size_t N) : std::vector<TPoint3D>(N) {}
50  /** Implicit constructor from a 3D points vector. */
51  TPolygon3D(const std::vector<TPoint3D>& v) : std::vector<TPoint3D>(v) {}
52  /** Constructor from a 2D object. Zeroes the z. */
53  explicit TPolygon3D(const TPolygon2D& p);
54  /** Static method to create a regular polygon, given its size and radius.
55  * \throw std::logic_error if number of edges is less than three, or radius
56  * is near zero. */
57  static void createRegularPolygon(
58  size_t numEdges, double radius, TPolygon3D& poly);
59  /** Static method to create a regular polygon, given its size and radius.
60  * The center will be located on the given pose.
61  * \throw std::logic_error if number of edges is less than three, or radius
62  * is near zero.
63  */
64  static void createRegularPolygon(
65  size_t numEdges, double radius, TPolygon3D& poly,
66  const mrpt::math::TPose3D& pose);
67 };
68 
69 } // namespace mrpt::math
70 
71 namespace mrpt::typemeta
72 {
73 // Specialization must occur in the same namespace
75 
76 } // namespace mrpt::typemeta
static void createRegularPolygon(size_t numEdges, double radius, TPolygon3D &poly)
Static method to create a regular polygon, given its size and radius.
TPolygon3D(const std::vector< TPoint3D > &v)
Implicit constructor from a 3D points vector.
Definition: TPolygon3D.h:51
bool isSkew() const
Check whether the polygon is skew.
TPolygon3D()
Default constructor.
Definition: TPolygon3D.h:46
STL namespace.
This base provides a set of functions for maths stuff.
void generate2DObject(TPolygon2D &p) const
Projects into a 2D space, discarding the z.
3D Plane, represented by its equation
Definition: TPlane.h:22
bool getPlane(TPlane &p) const
Gets a plane which contains the polygon.
void removeRedundantVertices()
Erase every redundant vertex, thus saving space.
#define MRPT_DECLARE_TTYPENAME_NO_NAMESPACE(_TYPE, __NS)
Declares a typename to be "type" (without the NS prefix)
Definition: TTypeName.h:128
bool contains(const TPoint3D &point) const
Check whether a point is inside (or within geometryEpsilon of a polygon edge).
double distance(const TPoint3D &point) const
Distance to point (always >=0)
const GLdouble * v
Definition: glext.h:3684
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:24
void removeRepeatedVertices()
Remove polygon&#39;s repeated vertices.
Lightweight 3D point.
Definition: TPoint3D.h:90
TPolygon3D(size_t N)
Constructor for a given size.
Definition: TPolygon3D.h:49
void getAsSegmentList(std::vector< TSegment3D > &v) const
Gets as set of segments, instead of set of points.
void getBestFittingPlane(TPlane &p) const
Gets the best fitting plane, disregarding whether the polygon actually fits inside or not...
GLfloat GLfloat p
Definition: glext.h:6398
2D polygon, inheriting from std::vector<TPoint2D>.
Definition: TPolygon2D.h:21
3D polygon, inheriting from std::vector<TPoint3D>
Definition: TPolygon3D.h:18
void getCenter(TPoint3D &p) const
Get polygon&#39;s central point.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 479715d5b Tue Nov 12 07:26:21 2019 +0100 at mar nov 12 07:30:12 CET 2019