Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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>
13 
14 namespace mrpt
15 {
16 namespace poses
17 {
18  DEFINE_SERIALIZABLE_PRE( CPoint3D )
19 
20  /** A class used to store a 3D point.
21  *
22  * For a complete description of Points/Poses, see mrpt::poses::CPoseOrPoint, or refer
23  * to the <a href="http://www.mrpt.org/2D_3D_Geometry" >2D/3D Geometry tutorial</a> in the wiki.
24  *
25  * <div align=center>
26  * <img src="CPoint3D.gif">
27  * </div>
28  *
29  * \ingroup poses_grp
30  * \sa CPoseOrPoint,CPose, CPoint
31  */
32  class BASE_IMPEXP CPoint3D : public CPoint<CPoint3D>, public mrpt::utils::CSerializable
33  {
34  // This must be added to any CSerializable derived class:
36 
37  public:
39 
40  public:
41  /** Constructor for initializing point coordinates. */
42  inline CPoint3D(const double x=0,const double y=0,const double z=0) { m_coords[0]= x; m_coords[1]=y; m_coords[2]=z; }
43 
44  /** Constructor from a XYZ 3-vector */
45  explicit inline CPoint3D(const mrpt::math::CArrayDouble<3> &xyz) : m_coords(xyz) { }
46 
47  /** Constructor from an CPoint2D object. */
48  explicit CPoint3D( const CPoint2D &p);
49 
50  /** Constructor from an CPose3D object. */
51  explicit CPoint3D( const CPose3D &p);
52 
53  /** Constructor from an CPose2D object. */
54  explicit CPoint3D( const CPose2D &p);
55 
56  /** Constructor from lightweight object. */
57  inline explicit CPoint3D(const mrpt::math::TPoint3D &p) { m_coords[0]=p.x; m_coords[1]=p.y; m_coords[2]=p.z; }
58 
59  /** Returns this point as seen from "b", i.e. result = this - b */
60  CPoint3D operator - (const CPose3D& b) const;
61 
62  /** Returns this point minus point "b", i.e. result = this - b */
63  CPoint3D operator - (const CPoint3D& b) const;
64 
65  /** Returns this point plus point "b", i.e. result = this + b */
66  CPoint3D operator + (const CPoint3D& b) const;
67 
68  /** Returns this point plus pose "b", i.e. result = this + b */
69  CPose3D operator + (const CPose3D& b) const;
70 
71 
72  enum { is_3D_val = 1 };
73  static inline bool is_3D() { return is_3D_val!=0; }
74 
75  enum { is_PDF_val = 0 };
76  static inline bool is_PDF() { return is_PDF_val!=0; }
77 
78  /** @name STL-like methods and typedefs
79  @{ */
80  typedef double value_type; //!< The type of the elements
81  typedef double& reference;
82  typedef const double& const_reference;
83  typedef std::size_t size_type;
85 
86 
87  // size is constant
88  enum { static_size = 3 };
89  static inline size_type size() { return static_size; }
90  static inline bool empty() { return false; }
91  static inline size_type max_size() { return static_size; }
92  static inline void resize(const size_t n) { if (n!=static_size) throw std::logic_error(format("Try to change the size of CPoint3D to %u.",static_cast<unsigned>(n))); }
93  /** @} */
94 
95  void setToNaN() MRPT_OVERRIDE;
96 
97  }; // End of class def.
99 
100 
101  } // End of namespace
102 } // End of namespace
103 
104 #endif
GLdouble GLdouble z
Definition: glext.h:3734
static bool is_PDF()
Definition: CPoint3D.h:76
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
#define DEFINE_SERIALIZABLE_PRE(class_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
mrpt::math::TPoint2D BASE_IMPEXP operator+(const CPose2D &pose, const mrpt::math::TPoint2D &pnt)
Compose a 2D point from a new coordinate base given by a 2D pose.
Definition: CPose2D.cpp:359
mrpt::math::CArrayDouble< 3 > m_coords
[x,y,z]
Definition: CPoint3D.h:38
double & reference
Definition: CPoint3D.h:81
GLenum GLsizei n
Definition: glext.h:4618
CPoint3D(const mrpt::math::TPoint3D &p)
Constructor from lightweight object.
Definition: CPoint3D.h:57
double value_type
The type of the elements.
Definition: CPoint3D.h:80
A base class for representing a point in 2D or 3D.
Definition: CPoint.h:26
CPoint3D(const mrpt::math::CArrayDouble< 3 > &xyz)
Constructor from a XYZ 3-vector.
Definition: CPoint3D.h:45
static bool empty()
Definition: CPoint3D.h:90
CPose2D BASE_IMPEXP operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
Definition: CPose2D.cpp:307
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:21
GLubyte GLubyte b
Definition: glext.h:5575
static bool is_3D()
Definition: CPoint3D.h:73
A class used to store a 2D point.
Definition: CPoint2D.h:36
A class used to store a 3D point.
Definition: CPoint3D.h:32
_W64 int ptrdiff_t
Definition: glew.h:133
std::size_t size_type
Definition: CPoint3D.h:83
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:89
std::ptrdiff_t difference_type
Definition: CPoint3D.h:84
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:36
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
CPoint3D(const double x=0, const double y=0, const double z=0)
Constructor for initializing point coordinates.
Definition: CPoint3D.h:42
GLenum GLint GLint y
Definition: glext.h:3516
static void resize(const size_t n)
Definition: CPoint3D.h:92
#define DEFINE_SERIALIZABLE_POST(class_name)
GLenum GLint x
Definition: glext.h:3516
Lightweight 3D point.
static size_type max_size()
Definition: CPoint3D.h:91
GLfloat GLfloat p
Definition: glext.h:5587
const double & const_reference
Definition: CPoint3D.h:82



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019