Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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
14namespace mrpt
15{
16namespace poses
17{
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 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 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;
84 typedef std::ptrdiff_t difference_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
96
97 }; // End of class def.
99
100
101 } // End of namespace
102} // End of namespace
103
104#endif
#define DEFINE_SERIALIZABLE_PRE(class_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_POST(class_name)
A partial specialization of CArrayNumeric for double numbers.
Definition: CArrayNumeric.h:75
A class used to store a 2D point.
Definition: CPoint2D.h:37
A class used to store a 3D point.
Definition: CPoint3D.h:33
std::size_t size_type
Definition: CPoint3D.h:83
static bool is_PDF()
Definition: CPoint3D.h:76
CPoint3D(const CPose3D &p)
Constructor from an CPose3D object.
static bool empty()
Definition: CPoint3D.h:90
std::ptrdiff_t difference_type
Definition: CPoint3D.h:84
CPoint3D(const mrpt::math::CArrayDouble< 3 > &xyz)
Constructor from a XYZ 3-vector.
Definition: CPoint3D.h:45
CPoint3D(const CPose2D &p)
Constructor from an CPose2D object.
static void resize(const size_t n)
Definition: CPoint3D.h:92
static bool is_3D()
Definition: CPoint3D.h:73
CPoint3D(const double x=0, const double y=0, const double z=0)
Constructor for initializing point coordinates.
Definition: CPoint3D.h:42
CPoint3D(const CPoint2D &p)
Constructor from an CPoint2D object.
CPoint3D(const mrpt::math::TPoint3D &p)
Constructor from lightweight object.
Definition: CPoint3D.h:57
const double & const_reference
Definition: CPoint3D.h:82
static size_type max_size()
Definition: CPoint3D.h:91
void setToNaN() MRPT_OVERRIDE
Set all data fields to quiet NaN.
double & reference
Definition: CPoint3D.h:81
static size_type size()
Definition: CPoint3D.h:89
double value_type
The type of the elements.
Definition: CPoint3D.h:80
mrpt::math::CArrayDouble< 3 > m_coords
[x,y,z]
Definition: CPoint3D.h:38
A base class for representing a point in 2D or 3D.
Definition: CPoint.h:27
A class used to store a 2D pose.
Definition: CPose2D.h:37
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
@ static_size
Definition: eigen_plugins.h:17
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
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...
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Lightweight 3D point.
double z
X,Y,Z coordinates.



Page generated by Doxygen 1.9.2 for MRPT 1.4.0 SVN: at Mon Sep 20 00:47:55 UTC 2021