00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 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 * \sa CPoseOrPoint,CPose, CPoint 00050 */ 00051 class BASE_IMPEXP CPoint3D : public CPoint<CPoint3D>, public mrpt::utils::CSerializable 00052 { 00053 // This must be added to any CSerializable derived class: 00054 DEFINE_SERIALIZABLE( CPoint3D ) 00055 00056 public: 00057 mrpt::math::CArrayDouble<3> m_coords; //!< [x,y,z] 00058 00059 public: 00060 /** Constructor for initializing point coordinates. */ 00061 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; } 00062 00063 /** Constructor from a XYZ 3-vector */ 00064 explicit inline CPoint3D(const mrpt::math::CArrayDouble<3> &xyz) : m_coords(xyz) { } 00065 00066 /** Constructor from an CPoint2D object. */ 00067 CPoint3D( const CPoint2D &p); 00068 00069 /** Constructor from an CPose3D object. */ 00070 explicit inline CPoint3D( const CPose3D &p) { m_coords[0]=p.x(); m_coords[1]=p.y(); m_coords[2]=p.z(); } 00071 00072 /** Constructor from an CPose2D object. */ 00073 explicit CPoint3D( const CPose2D &p); 00074 00075 /** Constructor from lightweight object. */ 00076 inline CPoint3D(const mrpt::math::TPoint3D &p) { m_coords[0]=p.x; m_coords[1]=p.y; m_coords[2]=p.z; } 00077 00078 /** Returns this point as seen from "b", i.e. result = this - b */ 00079 CPoint3D operator - (const CPose3D& b) const; 00080 00081 /** Returns this point minus point "b", i.e. result = this - b */ 00082 CPoint3D operator - (const CPoint3D& b) const; 00083 00084 /** Returns this point plus point "b", i.e. result = this + b */ 00085 CPoint3D operator + (const CPoint3D& b) const; 00086 00087 /** Returns this point plus pose "b", i.e. result = this + b */ 00088 CPose3D operator + (const CPose3D& b) const; 00089 00090 00091 enum { is_3D_val = 1 }; 00092 static inline bool is_3D() { return is_3D_val!=0; } 00093 00094 enum { is_PDF_val = 0 }; 00095 static inline bool is_PDF() { return is_PDF_val!=0; } 00096 00097 /** @name STL-like methods and typedefs 00098 @{ */ 00099 typedef double value_type; //!< The type of the elements 00100 typedef double& reference; 00101 typedef const double& const_reference; 00102 typedef std::size_t size_type; 00103 typedef std::ptrdiff_t difference_type; 00104 00105 00106 // size is constant 00107 enum { static_size = 3 }; 00108 static inline size_type size() { return static_size; } 00109 static inline bool empty() { return false; } 00110 static inline size_type max_size() { return static_size; } 00111 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))); } 00112 /** @} */ 00113 00114 }; // End of class def. 00115 00116 00117 } // End of namespace 00118 } // End of namespace 00119 00120 #endif
Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:30:30 UTC 2011 |