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 |
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
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
n
GLenum GLsizei n
Definition: glext.h:5074
mrpt::poses::CPoint2D::empty
static bool empty()
Definition: CPoint2D.h:108
mrpt::math::TPoint2D::y
double y
Definition: lightweight_geom_data.h:49
mrpt::poses::CPoint2D::size_type
std::size_t size_type
Definition: CPoint2D.h:99
mrpt::poses::CPoint
A base class for representing a point in 2D or 3D.
Definition: CPoint.h:27
mrpt::poses::CPoint2D::m_coords
mrpt::math::CArrayDouble< 2 > m_coords
[x,y]
Definition: CPoint2D.h:42
mrpt::poses::CPoint2D::const_reference
const double & const_reference
Definition: CPoint2D.h:98
mrpt::math::TPoint2D::x
double x
X,Y coordinates.
Definition: lightweight_geom_data.h:49
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::poses::CPoint2D::max_size
static size_type max_size()
Definition: CPoint2D.h:109
mrpt::poses::CPoseOrPoint
The base template class for 2D & 3D points and poses.
Definition: CPoseOrPoint.h:125
mrpt::poses::CPoint2D::reference
double & reference
Definition: CPoint2D.h:97
mrpt::poses::CPoint2D::CPoint2D
CPoint2D(const mrpt::math::TPoint2D &o)
Implicit constructor from lightweight type.
Definition: CPoint2D.h:61
mrpt::poses::CPoint2D::is_PDF_val
@ is_PDF_val
Definition: CPoint2D.h:90
mrpt::poses::CPoseOrPoint< CPoint2D >::y
double y() const
Definition: CPoseOrPoint.h:144
mrpt::poses::CPoint2D::static_size
@ static_size
Definition: CPoint2D.h:105
mrpt::poses::CPoint2D::operator-
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
mrpt::format
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
mrpt::poses::CPose2D
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:40
mrpt::poses::CPoseOrPoint< CPoint2D >::x
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
mrpt::math::TPoint3D::x
double x
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:385
b
GLubyte GLubyte b
Definition: glext.h:6279
mrpt::serialization::CSerializable
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:32
mrpt::poses::CPoint2D::asTPoint
mrpt::math::TPoint2D asTPoint() const
Definition: CPoint2D.cpp:72
mrpt::poses::CPoint2D::CPoint2D
CPoint2D(const CPoseOrPoint< OTHERCLASS > &b)
Constructor from x/y coordinates given from other pose.
Definition: CPoint2D.h:54
mrpt::poses::CPoint2D::is_3D_val
@ is_3D_val
Definition: CPoint2D.h:85
mrpt::math::CArrayNumeric
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
Definition: CArrayNumeric.h:25
mrpt::poses::CPoint2D::size
static size_type size()
Definition: CPoint2D.h:107
mrpt::math::TPoint2D
Lightweight 2D point.
Definition: lightweight_geom_data.h:42
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:385
mrpt::poses::CPoint2D::setToNaN
void setToNaN() override
Set all data fields to quiet NaN.
Definition: CPoint2D.cpp:66
CPoint.h
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
mrpt::poses::CPoint2D::CPoint2D
CPoint2D(const mrpt::math::TPoint3D &o)
Explicit constructor from lightweight type (loses the z coord).
Definition: CPoint2D.h:68
CArrayNumeric.h
mrpt::poses::CPoint2D::is_3D
static bool is_3D()
Definition: CPoint2D.h:87
mrpt::poses::CPoint2D::resize
static void resize(const size_t n)
Definition: CPoint2D.h:110
mrpt::poses::CPoint2D::CPoint2D
CPoint2D(double x=0, double y=0)
Constructor for initializing point coordinates.
Definition: CPoint2D.h:46
ptrdiff_t
_W64 int ptrdiff_t
Definition: glew.h:137
mrpt::poses::CPoint2D
A class used to store a 2D point.
Definition: CPoint2D.h:35
mrpt::poses::CPoint2D::is_PDF
static bool is_PDF()
Definition: CPoint2D.h:92
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538
mrpt::poses::CPoint2D::difference_type
std::ptrdiff_t difference_type
Definition: CPoint2D.h:100
mrpt::poses::CPoint2D::value_type
double value_type
The type of the elements.
Definition: CPoint2D.h:96



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST