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
mrpt::poses::CPoint3D::CPoint3D
CPoint3D(const mrpt::math::TPoint3D &p)
Constructor from lightweight object.
Definition: CPoint3D.h:67
mrpt::poses::CPoint3D::value_type
double value_type
The type of the elements.
Definition: CPoint3D.h:100
mrpt::poses::CPoint3D::m_coords
mrpt::math::CArrayDouble< 3 > m_coords
[x,y,z]
Definition: CPoint3D.h:40
n
GLenum GLsizei n
Definition: glext.h:5074
mrpt::poses::CPoint3D::max_size
static size_type max_size()
Definition: CPoint3D.h:113
mrpt::poses::CPoint3D::CPoint3D
CPoint3D(const double x=0, const double y=0, const double z=0)
Constructor for initializing point coordinates.
Definition: CPoint3D.h:44
mrpt::poses::CPoint
A base class for representing a point in 2D or 3D.
Definition: CPoint.h:27
mrpt::poses::CPoint3D::const_reference
const double & const_reference
Definition: CPoint3D.h:102
mrpt::poses::CPoint3D::CPoint3D
CPoint3D(const mrpt::math::CArrayDouble< 3 > &xyz)
Constructor from a XYZ 3-vector.
Definition: CPoint3D.h:52
mrpt::poses::CPoint3D::is_PDF
static bool is_PDF()
Definition: CPoint3D.h:96
mrpt::poses::CPoint3D::static_size
@ static_size
Definition: CPoint3D.h:109
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::poses::CPoint3D::setToNaN
void setToNaN() override
Set all data fields to quiet NaN.
Definition: CPoint3D.cpp:134
p
GLfloat GLfloat p
Definition: glext.h:6305
mrpt::poses::CPoint3D::empty
static bool empty()
Definition: CPoint3D.h:112
mrpt::poses::CPoint3D::is_PDF_val
@ is_PDF_val
Definition: CPoint3D.h:94
mrpt::poses::CPoseOrPoint< CPoint3D >::y
double y() const
Definition: CPoseOrPoint.h:144
mrpt::poses::CPoint3D::size_type
std::size_t size_type
Definition: CPoint3D.h:103
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< CPoint3D >::x
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
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::math::CArrayNumeric
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
Definition: CArrayNumeric.h:25
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::poses::CPoint3D::size
static size_type size()
Definition: CPoint3D.h:111
mrpt::poses::CPoint3D::is_3D_val
@ is_3D_val
Definition: CPoint3D.h:89
mrpt::poses::CPoint3D::operator+
CPoint3D operator+(const CPoint3D &b) const
Returns this point plus point "b", i.e.
Definition: CPoint3D.cpp:117
CPoint.h
mrpt::poses::CPoint3D::difference_type
std::ptrdiff_t difference_type
Definition: CPoint3D.h:104
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::CPoint3D::asTPoint
mrpt::math::TPoint3D asTPoint() const
Definition: CPoint3D.cpp:140
z
GLdouble GLdouble z
Definition: glext.h:3872
ptrdiff_t
_W64 int ptrdiff_t
Definition: glew.h:137
mrpt::poses::CPoint3D::operator-
CPoint3D operator-(const CPose3D &b) const
Returns this point as seen from "b", i.e.
Definition: CPoint3D.cpp:83
mrpt::poses::CPoint2D
A class used to store a 2D point.
Definition: CPoint2D.h:35
mrpt::poses::CPoint3D
A class used to store a 3D point.
Definition: CPoint3D.h:33
CSerializable.h
mrpt::poses::CPoint3D::reference
double & reference
Definition: CPoint3D.h:101
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538
mrpt::poses::CPoint3D::resize
static void resize(const size_t n)
Definition: CPoint3D.h:114
mrpt::poses::CPoint3D::is_3D
static bool is_3D()
Definition: CPoint3D.h:91



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