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

 Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019