MRPT  1.9.9
CPoint2D.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef CPOINT2D_H
10 #define CPOINT2D_H
11 
12 #include <mrpt/poses/CPoint.h>
14 
15 namespace mrpt::poses
16 {
17 class CPose2D;
18 
19 /** A class used to store a 2D point.
20  *
21  * For a complete description of Points/Poses, see mrpt::poses::CPoseOrPoint,
22  * or refer
23  * to the <a href="http://www.mrpt.org/2D_3D_Geometry" >2D/3D Geometry
24  * tutorial</a> in the wiki.
25  *
26  * <div align=center>
27  * <img src="CPoint2D.gif">
28  * </div>
29  *
30  * \sa CPoseOrPoint,CPose, CPoint
31  * \ingroup poses_grp
32  */
33 class CPoint2D : public CPoint<CPoint2D>,
35 {
37 
38  public:
39  /** [x,y] */
41 
42  public:
43  /** Constructor for initializing point coordinates. */
44  inline CPoint2D(double x = 0, double y = 0)
45  {
46  m_coords[0] = x;
47  m_coords[1] = y;
48  }
49 
50  /** Constructor from x/y coordinates given from other pose. */
51  template <class OTHERCLASS>
52  inline explicit CPoint2D(const CPoseOrPoint<OTHERCLASS>& b)
53  {
54  m_coords[0] = b.x();
55  m_coords[1] = b.y();
56  }
57 
58  /** Implicit constructor from lightweight type. */
59  inline explicit CPoint2D(const mrpt::math::TPoint2D& o)
60  {
61  m_coords[0] = o.x;
62  m_coords[1] = o.y;
63  }
64 
65  /** Explicit constructor from lightweight type (loses the z coord). */
66  inline explicit CPoint2D(const mrpt::math::TPoint3D& o)
67  {
68  m_coords[0] = o.x;
69  m_coords[1] = o.y;
70  m_coords[2] = 0;
71  }
72 
74 
75  /** The operator D="this"-b is the pose inverse compounding operator,
76  * the resulting points "D" fulfils: "this" = b + D, so that: b == a +
77  * (b-a)
78  */
79  CPoint2D operator-(const CPose2D& b) const;
80 
81  enum
82  {
84  };
85  static constexpr bool is_3D() { return is_3D_val != 0; }
86  enum
87  {
89  };
90  static constexpr bool is_PDF() { return is_PDF_val != 0; }
91  /** @name STL-like methods and typedefs
92  @{ */
93  /** The type of the elements */
94  using value_type = double;
95  using reference = double&;
96  using const_reference = const double&;
97  using size_type = std::size_t;
99 
100  // size is constant
101  enum
102  {
104  };
105  static constexpr size_type size() { return static_size; }
106  static constexpr bool empty() { return false; }
107  static constexpr size_type max_size() { return static_size; }
108  static inline void resize(const size_t n)
109  {
110  if (n != static_size)
111  throw std::logic_error(format(
112  "Try to change the size of CPoint2D to %u.",
113  static_cast<unsigned>(n)));
114  }
115  /** @} */
116 
117  void setToNaN() override;
118 
119 }; // End of class def.
120 
121 } // namespace mrpt::poses
122 #endif
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
double x
X,Y coordinates.
static constexpr bool is_PDF()
Definition: CPoint2D.h:90
static void resize(const size_t n)
Definition: CPoint2D.h:108
static constexpr bool empty()
Definition: CPoint2D.h:106
CPoint2D(const CPoseOrPoint< OTHERCLASS > &b)
Constructor from x/y coordinates given from other pose.
Definition: CPoint2D.h:52
mrpt::math::CArrayDouble< 2 > m_coords
[x,y]
Definition: CPoint2D.h:40
GLenum GLsizei n
Definition: glext.h:5074
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually...
Definition: CArrayNumeric.h:25
static constexpr size_type max_size()
Definition: CPoint2D.h:107
CPoint2D(const mrpt::math::TPoint2D &o)
Implicit constructor from lightweight type.
Definition: CPoint2D.h:59
A base class for representing a point in 2D or 3D.
Definition: CPoint.h:25
GLubyte GLubyte b
Definition: glext.h:6279
double x
X,Y,Z coordinates.
CPoint2D(double x=0, double y=0)
Constructor for initializing point coordinates.
Definition: CPoint2D.h:44
The base template class for 2D & 3D points and poses.
Definition: CPoseOrPoint.h:125
A class used to store a 2D point.
Definition: CPoint2D.h:33
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
double & reference
Definition: CPoint2D.h:95
_W64 int ptrdiff_t
Definition: glew.h:137
void setToNaN() override
Set all data fields to quiet NaN.
Definition: CPoint2D.cpp:66
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:38
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
std::ptrdiff_t difference_type
Definition: CPoint2D.h:98
double value_type
The type of the elements.
Definition: CPoint2D.h:94
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
CPoint2D operator-(const CPose2D &b) const
The operator D="this"-b is the pose inverse compounding operator, the resulting points "D" fulfils: "...
Definition: CPoint2D.cpp:56
GLenum GLint GLint y
Definition: glext.h:3538
mrpt::math::TPoint2D asTPoint() const
Definition: CPoint2D.cpp:72
CPoint2D(const mrpt::math::TPoint3D &o)
Explicit constructor from lightweight type (loses the z coord).
Definition: CPoint2D.h:66
GLenum GLint x
Definition: glext.h:3538
static constexpr bool is_3D()
Definition: CPoint2D.h:85
Lightweight 3D point.
Lightweight 2D point.
static constexpr size_type size()
Definition: CPoint2D.h:105
const double & const_reference
Definition: CPoint2D.h:96
std::size_t size_type
Definition: CPoint2D.h:97



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020