00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef CPOINT3D_H 00029 #define CPOINT3D_H 00030 00031 #include <mrpt/poses/CPoint.h> 00032 #include <mrpt/poses/CPose3D.h> 00033 00034 namespace mrpt 00035 { 00036 namespace poses 00037 { 00038 DEFINE_SERIALIZABLE_PRE( CPoint3D ) 00039 00040 /** A class used to store a 3D point. 00041 * 00042 * For a complete description of Points/Poses, see mrpt::poses::CPoseOrPoint, or refer 00043 * to the <a href="http://www.mrpt.org/2D_3D_Geometry" >2D/3D Geometry tutorial</a> in the wiki. 00044 * 00045 * <div align=center> 00046 * <img src="CPoint3D.gif"> 00047 * </div> 00048 * 00049 * \ingroup poses_grp 00050 * \sa CPoseOrPoint,CPose, CPoint 00051 */ 00052 class BASE_IMPEXP CPoint3D : public CPoint<CPoint3D>, public mrpt::utils::CSerializable 00053 { 00054 // This must be added to any CSerializable derived class: 00055 DEFINE_SERIALIZABLE( CPoint3D ) 00056 00057 public: 00058 mrpt::math::CArrayDouble<3> m_coords; //!< [x,y,z] 00059 00060 public: 00061 /** Constructor for initializing point coordinates. */ 00062 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; } 00063 00064 /** Constructor from a XYZ 3-vector */ 00065 explicit inline CPoint3D(const mrpt::math::CArrayDouble<3> &xyz) : m_coords(xyz) { } 00066 00067 /** Constructor from an CPoint2D object. */ 00068 CPoint3D( const CPoint2D &p); 00069 00070 /** Constructor from an CPose3D object. */ 00071 explicit inline CPoint3D( const CPose3D &p) { m_coords[0]=p.x(); m_coords[1]=p.y(); m_coords[2]=p.z(); } 00072 00073 /** Constructor from an CPose2D object. */ 00074 explicit CPoint3D( const CPose2D &p); 00075 00076 /** Constructor from lightweight object. */ 00077 inline CPoint3D(const mrpt::math::TPoint3D &p) { m_coords[0]=p.x; m_coords[1]=p.y; m_coords[2]=p.z; } 00078 00079 /** Returns this point as seen from "b", i.e. result = this - b */ 00080 CPoint3D operator - (const CPose3D& b) const; 00081 00082 /** Returns this point minus point "b", i.e. result = this - b */ 00083 CPoint3D operator - (const CPoint3D& b) const; 00084 00085 /** Returns this point plus point "b", i.e. result = this + b */ 00086 CPoint3D operator + (const CPoint3D& b) const; 00087 00088 /** Returns this point plus pose "b", i.e. result = this + b */ 00089 CPose3D operator + (const CPose3D& b) const; 00090 00091 00092 enum { is_3D_val = 1 }; 00093 static inline bool is_3D() { return is_3D_val!=0; } 00094 00095 enum { is_PDF_val = 0 }; 00096 static inline bool is_PDF() { return is_PDF_val!=0; } 00097 00098 /** @name STL-like methods and typedefs 00099 @{ */ 00100 typedef double value_type; //!< The type of the elements 00101 typedef double& reference; 00102 typedef const double& const_reference; 00103 typedef std::size_t size_type; 00104 typedef std::ptrdiff_t difference_type; 00105 00106 00107 // size is constant 00108 enum { static_size = 3 }; 00109 static inline size_type size() { return static_size; } 00110 static inline bool empty() { return false; } 00111 static inline size_type max_size() { return static_size; } 00112 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))); } 00113 /** @} */ 00114 00115 }; // End of class def. 00116 00117 00118 } // End of namespace 00119 } // End of namespace 00120 00121 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |