MRPT  1.9.9
CPoint3D.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 CPOINT3D_H
10 #define CPOINT3D_H
11
12 #include <mrpt/poses/CPoint.h>
14
15 namespace mrpt::poses
16 {
17 /** A class used to store a 3D point.
18  *
19  * For a complete description of Points/Poses, see mrpt::poses::CPoseOrPoint,
20  * or refer
21  * to the <a href="http://www.mrpt.org/2D_3D_Geometry" >2D/3D Geometry
22  * tutorial</a> in the wiki.
23  *
24  * <div align=center>
25  * <img src="CPoint3D.gif">
26  * </div>
27  *
28  * \ingroup poses_grp
29  * \sa CPoseOrPoint,CPose, CPoint
30  */
31 class CPoint3D : public CPoint<CPoint3D>,
33 {
35
36  public:
37  /** [x,y,z] */
39
40  public:
41  /** Constructor for initializing point coordinates. */
42  inline CPoint3D(const double x = 0, const double y = 0, const double z = 0)
43  {
44  m_coords[0] = x;
45  m_coords[1] = y;
46  m_coords[2] = z;
47  }
48
49  /** Constructor from a XYZ 3-vector */
50  explicit inline CPoint3D(const mrpt::math::CArrayDouble<3>& xyz)
51  : m_coords(xyz)
52  {
53  }
54
55  /** Constructor from an CPoint2D object. */
56  explicit CPoint3D(const CPoint2D& p);
57
58  /** Constructor from an CPose3D object. */
59  explicit CPoint3D(const CPose3D& p);
60
61  /** Constructor from an CPose2D object. */
62  explicit CPoint3D(const CPose2D& p);
63
64  /** Constructor from lightweight object. */
65  inline explicit CPoint3D(const mrpt::math::TPoint3D& p)
66  {
67  m_coords[0] = p.x;
68  m_coords[1] = p.y;
69  m_coords[2] = p.z;
70  }
72
73  /** Returns this point as seen from "b", i.e. result = this - b */
74  CPoint3D operator-(const CPose3D& b) const;
75
76  /** Returns this point minus point "b", i.e. result = this - b */
77  CPoint3D operator-(const CPoint3D& b) const;
78
79  /** Returns this point plus point "b", i.e. result = this + b */
80  CPoint3D operator+(const CPoint3D& b) const;
81
82  /** Returns this point plus pose "b", i.e. result = this + b */
83  CPose3D operator+(const CPose3D& b) const;
84
85  enum
86  {
88  };
89  static constexpr bool is_3D() { return is_3D_val != 0; }
90  enum
91  {
93  };
94  static constexpr bool is_PDF() { return is_PDF_val != 0; }
95  /** @name STL-like methods and typedefs
96  @{ */
97  /** The type of the elements */
98  using value_type = double;
99  using reference = double&;
100  using const_reference = const double&;
101  using size_type = std::size_t;
103
104  // size is constant
105  enum
106  {
108  };
109  static constexpr size_type size() { return static_size; }
110  static constexpr bool empty() { return false; }
111  static constexpr size_type max_size() { return static_size; }
112  static inline void resize(const size_t n)
113  {
114  if (n != static_size)
115  throw std::logic_error(format(
116  "Try to change the size of CPoint3D to %u.",
117  static_cast<unsigned>(n)));
118  }
119  /** @} */
120
121  void setToNaN() override;
122
123 }; // End of class def.
124
125 } // namespace mrpt::poses
126 #endif
const double & const_reference
Definition: CPoint3D.h:100
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
GLdouble GLdouble z
Definition: glext.h:3872
static constexpr bool is_3D()
Definition: CPoint3D.h:89
double & reference
Definition: CPoint3D.h:99
void setToNaN() override
Set all data fields to quiet NaN.
Definition: CPoint3D.cpp:134
mrpt::math::CArrayDouble< 3 > m_coords
[x,y,z]
Definition: CPoint3D.h:38
GLenum GLsizei n
Definition: glext.h:5074
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually...
Definition: CArrayNumeric.h:25
CPoint3D(const mrpt::math::TPoint3D &p)
Constructor from lightweight object.
Definition: CPoint3D.h:65
static constexpr bool empty()
Definition: CPoint3D.h:110
static constexpr size_type size()
Definition: CPoint3D.h:109
A base class for representing a point in 2D or 3D.
Definition: CPoint.h:25
CPoint3D(const mrpt::math::CArrayDouble< 3 > &xyz)
Constructor from a XYZ 3-vector.
Definition: CPoint3D.h:50
GLubyte GLubyte b
Definition: glext.h:6279
A class used to store a 2D point.
Definition: CPoint2D.h:33
A class used to store a 3D point.
Definition: CPoint3D.h:31
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
_W64 int ptrdiff_t
Definition: glew.h:137
mrpt::math::TPoint3D asTPoint() const
Definition: CPoint3D.cpp:140
std::size_t size_type
Definition: CPoint3D.h:101
#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
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
CPoint3D operator-(const CPose3D &b) const
Returns this point as seen from "b", i.e.
Definition: CPoint3D.cpp:83
double value_type
The type of the elements.
Definition: CPoint3D.h:98
CPoint3D(const double x=0, const double y=0, const double z=0)
Constructor for initializing point coordinates.
Definition: CPoint3D.h:42
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
GLenum GLint GLint y
Definition: glext.h:3538
static void resize(const size_t n)
Definition: CPoint3D.h:112
static constexpr bool is_PDF()
Definition: CPoint3D.h:94
GLenum GLint x
Definition: glext.h:3538
Lightweight 3D point.
CPoint3D operator+(const CPoint3D &b) const
Returns this point plus point "b", i.e.
Definition: CPoint3D.cpp:117
GLfloat GLfloat p
Definition: glext.h:6305
std::ptrdiff_t difference_type
Definition: CPoint3D.h:102
static constexpr size_type max_size()
Definition: CPoint3D.h:111

 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