Main MRPT website > C++ reference for 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 |
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 CPOINT3D_H
10 #define CPOINT3D_H
11 
12 #include <mrpt/poses/CPoint.h>
14 
15 namespace mrpt
16 {
17 namespace poses
18 {
19 /** A class used to store a 3D 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="CPoint3D.gif">
28  * </div>
29  *
30  * \ingroup poses_grp
31  * \sa CPoseOrPoint,CPose, CPoint
32  */
33 class CPoint3D : public CPoint<CPoint3D>,
35 {
37 
38  public:
39  /** [x,y,z] */
41 
42  public:
43  /** Constructor for initializing point coordinates. */
44  inline CPoint3D(const double x = 0, const double y = 0, const double z = 0)
45  {
46  m_coords[0] = x;
47  m_coords[1] = y;
48  m_coords[2] = z;
49  }
50 
51  /** Constructor from a XYZ 3-vector */
52  explicit inline CPoint3D(const mrpt::math::CArrayDouble<3>& xyz)
53  : m_coords(xyz)
54  {
55  }
56 
57  /** Constructor from an CPoint2D object. */
58  explicit CPoint3D(const CPoint2D& p);
59 
60  /** Constructor from an CPose3D object. */
61  explicit CPoint3D(const CPose3D& p);
62 
63  /** Constructor from an CPose2D object. */
64  explicit CPoint3D(const CPose2D& p);
65 
66  /** Constructor from lightweight object. */
67  inline explicit CPoint3D(const mrpt::math::TPoint3D& p)
68  {
69  m_coords[0] = p.x;
70  m_coords[1] = p.y;
71  m_coords[2] = p.z;
72  }
74 
75  /** Returns this point as seen from "b", i.e. result = this - b */
76  CPoint3D operator-(const CPose3D& b) const;
77 
78  /** Returns this point minus point "b", i.e. result = this - b */
79  CPoint3D operator-(const CPoint3D& b) const;
80 
81  /** Returns this point plus point "b", i.e. result = this + b */
82  CPoint3D operator+(const CPoint3D& b) const;
83 
84  /** Returns this point plus pose "b", i.e. result = this + b */
85  CPose3D operator+(const CPose3D& b) const;
86 
87  enum
88  {
90  };
91  static inline bool is_3D() { return is_3D_val != 0; }
92  enum
93  {
95  };
96  static inline bool is_PDF() { return is_PDF_val != 0; }
97  /** @name STL-like methods and typedefs
98  @{ */
99  /** The type of the elements */
100  using value_type = double;
101  using reference = double&;
102  using const_reference = const double&;
103  using size_type = std::size_t;
105 
106  // size is constant
107  enum
108  {
110  };
111  static inline size_type size() { return static_size; }
112  static inline bool empty() { return false; }
113  static inline size_type max_size() { return static_size; }
114  static inline void resize(const size_t n)
115  {
116  if (n != static_size)
117  throw std::logic_error(
118  format(
119  "Try to change the size of CPoint3D to %u.",
120  static_cast<unsigned>(n)));
121  }
122  /** @} */
123 
124  void setToNaN() override;
125 
126 }; // End of class def.
127 
128 } // End of namespace
129 } // End of namespace
130 
131 #endif
const double & const_reference
Definition: CPoint3D.h:102
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
GLdouble GLdouble z
Definition: glext.h:3872
static bool is_PDF()
Definition: CPoint3D.h:96
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:40
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:67
A base class for representing a point in 2D or 3D.
Definition: CPoint.h:27
CPoint3D(const mrpt::math::CArrayDouble< 3 > &xyz)
Constructor from a XYZ 3-vector.
Definition: CPoint3D.h:52
static bool empty()
Definition: CPoint3D.h:112
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
static bool is_3D()
Definition: CPoint3D.h:91
A class used to store a 2D point.
Definition: CPoint2D.h:35
A class used to store a 3D point.
Definition: CPoint3D.h:33
_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:103
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...
static size_type size()
Definition: CPoint3D.h:111
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
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:100
CPoint3D(const double x=0, const double y=0, const double z=0)
Constructor for initializing point coordinates.
Definition: CPoint3D.h:44
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:32
GLenum GLint GLint y
Definition: glext.h:3538
static void resize(const size_t n)
Definition: CPoint3D.h:114
GLenum GLint x
Definition: glext.h:3538
Lightweight 3D point.
static size_type max_size()
Definition: CPoint3D.h:113
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:104



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