00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2010 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 CPOSEORPOINT_H 00029 #define CPOSEORPOINT_H 00030 00031 #include <mrpt/utils/CSerializable.h> 00032 #include <mrpt/math/CMatrixFixedNumeric.h> 00033 #include <mrpt/math/lightweight_geom_data.h> 00034 #include <mrpt/math/ops_matrices.h> // Added here so many classes have access to these templates 00035 00036 namespace mrpt 00037 { 00038 /** Classes for 2D/3D geometry representation, both of single values and probability density distributions (PDFs) in many forms. 00039 */ 00040 namespace poses 00041 { 00042 using namespace mrpt::utils; // For square 00043 using namespace mrpt::math; // For ligh. geom data 00044 00045 // For use in some constructors (eg. CPose3D) 00046 enum TConstructorFlags_Poses 00047 { 00048 UNINITIALIZED_POSE = 0 00049 }; 00050 00051 class CPoint2D; 00052 class CPoint3D; 00053 class CPose2D; 00054 class CPose3D; 00055 00056 // This must be added to any CSerializable derived class: 00057 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CPoseOrPoint, mrpt::utils::CSerializable ) 00058 00059 /** The base class for 2D points, 3D points, 2D poses and 3D poses. 00060 * The common part defined in this base is the N-dimensional (N=2,3) 00061 * <b>position</b> vector. The existence of orientation angles is 00062 * left to derived classes. 00063 * In this class euclidean distance methods and operators are implemented. 00064 * 00065 * For more information and examples, refer 00066 * to the <a href="http://www.mrpt.org/2D_3D_Geometry">2D/3D Geometry tutorial</a> in the wiki. 00067 * 00068 00069 <center><h2>Introduction to 2D and 3D representation classes</h2></center> 00070 <hr> 00071 <p> 00072 There are two class of spatial representation classes: 00073 - Point: A point in the common mathematical sense, with no directional information. 00074 - 2D: A 2D point is represented just by its coordinates (x,y). 00075 - 3D: A 3D point is represented by its coordinates (x,y,z). 00076 - Pose: It is a point, plus a direction. 00077 - 2D: A 2D pose is a 2D point plus a single angle, the yaw or φ angle: the angle from the positive X angle. 00078 - 3D: A 3D point is a 3D point plus three orientation angles (More details above). 00079 </p> 00080 In the case for a 3D orientation many representation angles can be used (Euler angles,yaw/pitch/roll,...) 00081 but all of them can be handled by a 4x4 matrix called "Homogeneous Matrix". This matrix includes both, the 00082 translation and the orientation for a point or a pose, and it can be obtained using 00083 the method getHomogeneousMatrix() which is defined for any pose or point. Note that when the YPR angles are 00084 used to define a 3D orientation, these three values can not be extracted from the matrix again.<br><br> 00085 00086 <b>Operators:</b> There are operators defined for the pose compounding (+) and inverse pose 00087 compounding (-) of poses and points. For example, let "a" and "b" be 2D or 3D poses. Then "a+b" 00088 returns the resulting pose of "moving b" from "a"; and "b-a" returns the pose of "b" as it is seen 00089 "from a". They can be mixed points and poses, being 2D or 3D, in these operators, with the following 00090 results: <br> 00091 <center> 00092 Does "a+b"returns a Pose or a Point? 00093 <table> 00094 <tr> 00095 <td><b>a \ b</b></td> 00096 <td><b>Pose</b></td> 00097 <td><b>Point</b></td> 00098 </tr> 00099 <tr> 00100 <td><b>Pose</b></td> 00101 <td>Pose</td> 00102 <td>Point</td> 00103 </tr> 00104 <tr> 00105 <td><b>Point</b></td> 00106 <td>Pose</td> 00107 <td>Point</td> 00108 </tr> 00109 </table> 00110 </center> 00111 <br> 00112 <center> 00113 Does "a-b"returns a Pose or a Point? 00114 <table> 00115 <tr> 00116 <td><b>a \ b</b></td> 00117 <td><b>Pose</b></td> 00118 <td><b>Point</b></td> 00119 </tr> 00120 <tr> 00121 <td><b>Pose</b></td> 00122 <td>Pose</td> 00123 <td>Pose</td> 00124 </tr> 00125 <tr> 00126 <td><b>Point</b></td> 00127 <td>Point</td> 00128 <td>Point</td> 00129 </tr> 00130 </table> 00131 </center> 00132 <br> 00133 <center> 00134 Does "a+b"(and "a-b") returns a 2D or a 3D object? 00135 <table> 00136 <tr> 00137 <td><b>a \ b</b></td> 00138 <td><b>2D</b></td> 00139 <td><b>3D</b></td> 00140 </tr> 00141 <tr> 00142 <td><b>2D</b></td> 00143 <td>2D</td> 00144 <td>3D</td> 00145 </tr> 00146 <tr> 00147 <td><b>3D</b></td> 00148 <td>3D</td> 00149 <td>3D</td> 00150 </tr> 00151 </table> 00152 </center> 00153 <br><br> 00154 <b>Homogeneous matrices:</b> The matrices computation follows the equations that can be found in 00155 any introductory text to spatial orientations, which are exposed next:<br> 00156 00157 <div align=center> 00158 00159 <table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 00160 style='border-collapse:collapse;border:none'> 00161 <tr> 00162 <td width=576 colspan=2 style='width:432.2pt;border:solid windowtext 1.0pt; 00163 background:#E6E6E6;padding:0cm 5.4pt 0cm 5.4pt'> 00164 <p align=center style='text-align:center'>poses::CPoint2D</p> 00165 </td> 00166 </tr> 00167 <tr> 00168 <td width=288 style='width:216.1pt;border:solid windowtext 1.0pt;border-top: 00169 none;padding:0cm 5.4pt 0cm 5.4pt'> 00170 <p align=center style='text-align:center'>Homogeneous 00171 transfomation matrix</p> 00172 </td> 00173 <td width=288 style='width:216.1pt;border-top:none;border-left:none; 00174 border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; 00175 padding:0cm 5.4pt 0cm 5.4pt'> 00176 <p align=center style='text-align:center'>Spatial 00177 representation</p> 00178 </td> 00179 </tr> 00180 <tr style='height:108.3pt'> 00181 <td width=288 style='width:216.1pt;border:solid windowtext 1.0pt;border-top: 00182 none;padding:0cm 5.4pt 0cm 5.4pt;height:108.3pt'> 00183 <div align=center> 00184 <table Table border=0 cellspacing=0 cellpadding=0 width="46%" 00185 style='width:46.84%;border-collapse:collapse'> 00186 <tr style='height:16.5pt'> 00187 <td width=32 style='width:24.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00188 <p align=center style='text-align:center'>1</p> 00189 </td> 00190 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00191 <p align=center style='text-align:center'>0</p> 00192 </td> 00193 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00194 <p align=center style='text-align:center'>0</p> 00195 </td> 00196 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00197 <p align=center style='text-align:center'>x</p> 00198 </td> 00199 </tr> 00200 <tr style='height:16.5pt'> 00201 <td width=32 style='width:24.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00202 <p align=center style='text-align:center'>0</p> 00203 </td> 00204 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00205 <p align=center style='text-align:center'>1</p> 00206 </td> 00207 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00208 <p align=center style='text-align:center'>0</p> 00209 </td> 00210 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00211 <p align=center style='text-align:center'>y</p> 00212 </td> 00213 </tr> 00214 <tr style='height:16.5pt'> 00215 <td width=32 style='width:24.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00216 <p align=center style='text-align:center'>0</p> 00217 </td> 00218 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00219 <p align=center style='text-align:center'>0</p> 00220 </td> 00221 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00222 <p align=center style='text-align:center'>1</p> 00223 </td> 00224 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00225 <p align=center style='text-align:center'>0</p> 00226 </td> 00227 </tr> 00228 <tr style='height:16.5pt'> 00229 <td width=32 style='width:24.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00230 <p align=center style='text-align:center'>0</p> 00231 </td> 00232 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00233 <p align=center style='text-align:center'>0</p> 00234 </td> 00235 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00236 <p align=center style='text-align:center'>0</p> 00237 </td> 00238 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00239 <p align=center style='text-align:center'>1</p> 00240 </td> 00241 </tr> 00242 </table> 00243 </div> 00244 <p align=center style='text-align:center'></p> 00245 </td> 00246 <td width=288 style='width:216.1pt;border-top:none;border-left:none; 00247 border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; 00248 padding:0cm 5.4pt 0cm 5.4pt;height:108.3pt'> 00249 <p align=center style='text-align:center'><img src="CPoint2D.gif"></p> 00250 </td> 00251 </tr> 00252 </table> 00253 00254 </div> 00255 00256 <p></p> 00257 00258 <div align=center> 00259 00260 <table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 00261 style='border-collapse:collapse;border:none'> 00262 <tr> 00263 <td width=576 colspan=2 style='width:432.2pt;border:solid windowtext 1.0pt; 00264 background:#E6E6E6;padding:0cm 5.4pt 0cm 5.4pt'> 00265 <p align=center style='text-align:center'>poses::CPoint3D</p> 00266 </td> 00267 </tr> 00268 <tr> 00269 <td width=288 style='width:216.1pt;border:solid windowtext 1.0pt;border-top: 00270 none;padding:0cm 5.4pt 0cm 5.4pt'> 00271 <p align=center style='text-align:center'>Homogeneous 00272 transfomation matrix</p> 00273 </td> 00274 <td width=288 style='width:216.1pt;border-top:none;border-left:none; 00275 border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; 00276 padding:0cm 5.4pt 0cm 5.4pt'> 00277 <p align=center style='text-align:center'>Spatial 00278 representation</p> 00279 </td> 00280 </tr> 00281 <tr style='height:108.3pt'> 00282 <td width=288 style='width:216.1pt;border:solid windowtext 1.0pt;border-top: 00283 none;padding:0cm 5.4pt 0cm 5.4pt;height:108.3pt'> 00284 <div align=center> 00285 <table Table border=0 cellspacing=0 cellpadding=0 width="46%" 00286 style='width:46.84%;border-collapse:collapse'> 00287 <tr style='height:16.5pt'> 00288 <td width=32 style='width:24.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00289 <p align=center style='text-align:center'>1</p> 00290 </td> 00291 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00292 <p align=center style='text-align:center'>0</p> 00293 </td> 00294 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00295 <p align=center style='text-align:center'>0</p> 00296 </td> 00297 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00298 <p align=center style='text-align:center'>x</p> 00299 </td> 00300 </tr> 00301 <tr style='height:16.5pt'> 00302 <td width=32 style='width:24.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00303 <p align=center style='text-align:center'>0</p> 00304 </td> 00305 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00306 <p align=center style='text-align:center'>1</p> 00307 </td> 00308 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00309 <p align=center style='text-align:center'>0</p> 00310 </td> 00311 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00312 <p align=center style='text-align:center'>y</p> 00313 </td> 00314 </tr> 00315 <tr style='height:16.5pt'> 00316 <td width=32 style='width:24.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00317 <p align=center style='text-align:center'>0</p> 00318 </td> 00319 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00320 <p align=center style='text-align:center'>0</p> 00321 </td> 00322 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00323 <p align=center style='text-align:center'>1</p> 00324 </td> 00325 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00326 <p align=center style='text-align:center'>z</p> 00327 </td> 00328 </tr> 00329 <tr style='height:16.5pt'> 00330 <td width=32 style='width:24.0pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00331 <p align=center style='text-align:center'>0</p> 00332 </td> 00333 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00334 <p align=center style='text-align:center'>0</p> 00335 </td> 00336 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00337 <p align=center style='text-align:center'>0</p> 00338 </td> 00339 <td width=32 style='width:24.05pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.5pt'> 00340 <p align=center style='text-align:center'>1</p> 00341 </td> 00342 </tr> 00343 </table> 00344 </div> 00345 <p align=center style='text-align:center'></p> 00346 </td> 00347 <td width=288 style='width:216.1pt;border-top:none;border-left:none; 00348 border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; 00349 padding:0cm 5.4pt 0cm 5.4pt;height:108.3pt'> 00350 <p align=center style='text-align:center'><img src="CPoint3D.gif"></p> 00351 </td> 00352 </tr> 00353 </table> 00354 00355 </div> 00356 00357 <p></p> 00358 00359 <div align=center> 00360 00361 <table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 00362 style='border-collapse:collapse;border:none'> 00363 <tr> 00364 <td width=576 colspan=2 style='width:432.2pt;border:solid windowtext 1.0pt; 00365 background:#E6E6E6;padding:0cm 5.4pt 0cm 5.4pt'> 00366 <p align=center style='text-align:center'>poses::CPose2D</p> 00367 </td> 00368 </tr> 00369 <tr> 00370 <td width=288 style='width:216.1pt;border:solid windowtext 1.0pt;border-top: 00371 none;padding:0cm 5.4pt 0cm 5.4pt'> 00372 <p align=center style='text-align:center'>Homogeneous 00373 transfomation matrix</p> 00374 </td> 00375 <td width=288 style='width:216.1pt;border-top:none;border-left:none; 00376 border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; 00377 padding:0cm 5.4pt 0cm 5.4pt'> 00378 <p align=center style='text-align:center'>Spatial 00379 representation</p> 00380 </td> 00381 </tr> 00382 <tr style='height:108.3pt'> 00383 <td width=288 style='width:216.1pt;border:solid windowtext 1.0pt;border-top: 00384 none;padding:0cm 5.4pt 0cm 5.4pt;height:108.3pt'> 00385 <div align=center> 00386 <table Table border=0 cellspacing=0 cellpadding=0 width="67%" 00387 style='width:67.92%;border-collapse:collapse'> 00388 <tr style='height:20.6pt'> 00389 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00390 <p align=center style='text-align:center'>cos<span 00391 style='font-family:Symbol'>j</span></p> 00392 </td> 00393 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00394 <p align=center style='text-align:center'>-sin<span 00395 style='font-family:Symbol'>j</span></p> 00396 </td> 00397 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00398 <p align=center style='text-align:center'>0</p> 00399 </td> 00400 <td width=47 style='width:34.9pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00401 <p align=center style='text-align:center'>x</p> 00402 </td> 00403 </tr> 00404 <tr style='height:20.6pt'> 00405 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00406 <p align=center style='text-align:center'>sin<span 00407 style='font-family:Symbol'>j</span></p> 00408 </td> 00409 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00410 <p align=center style='text-align:center'>cos<span 00411 style='font-family:Symbol'>j</span></p> 00412 </td> 00413 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00414 <p align=center style='text-align:center'>0</p> 00415 </td> 00416 <td width=47 style='width:34.9pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00417 <p align=center style='text-align:center'>y</p> 00418 </td> 00419 </tr> 00420 <tr style='height:20.6pt'> 00421 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00422 <p align=center style='text-align:center'>0</p> 00423 </td> 00424 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00425 <p align=center style='text-align:center'>0</p> 00426 </td> 00427 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00428 <p align=center style='text-align:center'>1</p> 00429 </td> 00430 <td width=47 style='width:34.9pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00431 <p align=center style='text-align:center'>0</p> 00432 </td> 00433 </tr> 00434 <tr style='height:20.6pt'> 00435 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00436 <p align=center style='text-align:center'>0</p> 00437 </td> 00438 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00439 <p align=center style='text-align:center'>0</p> 00440 </td> 00441 <td width=46 style='width:34.85pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00442 <p align=center style='text-align:center'>0</p> 00443 </td> 00444 <td width=47 style='width:34.9pt;padding:0cm 5.4pt 0cm 5.4pt;height:20.6pt'> 00445 <p align=center style='text-align:center'>1</p> 00446 </td> 00447 </tr> 00448 </table> 00449 </div> 00450 <p align=center style='text-align:center'></p> 00451 </td> 00452 <td width=288 style='width:216.1pt;border-top:none;border-left:none; 00453 border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; 00454 padding:0cm 5.4pt 0cm 5.4pt;height:108.3pt'> 00455 <p align=center style='text-align:center'><img src="CPose2D.gif"></p> 00456 </td> 00457 </tr> 00458 </table> 00459 00460 </div> 00461 00462 <p></p> 00463 00464 <div align=center> 00465 00466 <table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 00467 style='border-collapse:collapse;border:none'> 00468 <tr style='height:15.8pt'> 00469 <td width=676 colspan=2 style='width:507.25pt;border:solid windowtext 1.0pt; 00470 background:#E6E6E6;padding:0cm 5.4pt 0cm 5.4pt;height:15.8pt'> 00471 <p align=center style='text-align:center'>poses::CPose3D</p> 00472 </td> 00473 </tr> 00474 <tr style='height:15.8pt'> 00475 <td width=350 style='width:262.65pt;border:solid windowtext 1.0pt;border-top: 00476 none;padding:0cm 5.4pt 0cm 5.4pt;height:15.8pt'> 00477 <p align=center style='text-align:center'>Homogeneous 00478 transfomation matrix</p> 00479 </td> 00480 <td width=326 style='width:244.6pt;border-top:none;border-left:none; 00481 border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; 00482 padding:0cm 5.4pt 0cm 5.4pt;height:15.8pt'> 00483 <p align=center style='text-align:center'>Spatial 00484 representation</p> 00485 </td> 00486 </tr> 00487 <tr style='height:202.65pt'> 00488 <td width=350 style='width:262.65pt;border:solid windowtext 1.0pt;border-top: 00489 none;padding:0cm 5.4pt 0cm 5.4pt;height:202.65pt'> 00490 <div align=center> 00491 <table Table border=0 cellspacing=0 cellpadding=0 width=334 00492 style='width:250.65pt;border-collapse:collapse'> 00493 <tr style='height:16.65pt'> 00494 <td width=66 style='width:49.65pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.65pt'> 00495 <p align=center style='text-align:center'>cycp</p> 00496 </td> 00497 <td width=99 style='width:74.15pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.65pt'> 00498 <p align=center style='text-align:center'>cyspsr-sycr</p> 00499 </td> 00500 <td width=87 style='width:65.55pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.65pt'> 00501 <p align=center style='text-align:center'>cyspcr+sysr</p> 00502 </td> 00503 <td width=82 style='width:61.3pt;padding:0cm 5.4pt 0cm 5.4pt;height:16.65pt'> 00504 <p align=center style='text-align:center'>x</p> 00505 </td> 00506 </tr> 00507 <tr style='height:17.25pt'> 00508 <td width=66 style='width:49.65pt;padding:0cm 5.4pt 0cm 5.4pt;height:17.25pt'> 00509 <p align=center style='text-align:center'>sycp</p> 00510 </td> 00511 <td width=99 style='width:74.15pt;padding:0cm 5.4pt 0cm 5.4pt;height:17.25pt'> 00512 <p align=center style='text-align:center'>syspsr+cycr</p> 00513 </td> 00514 <td width=87 style='width:65.55pt;padding:0cm 5.4pt 0cm 5.4pt;height:17.25pt'> 00515 <p align=center style='text-align:center'>syspcr-cysr</p> 00516 </td> 00517 <td width=82 style='width:61.3pt;padding:0cm 5.4pt 0cm 5.4pt;height:17.25pt'> 00518 <p align=center style='text-align:center'>y</p> 00519 </td> 00520 </tr> 00521 <tr style='height:19.65pt'> 00522 <td width=66 style='width:49.65pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.65pt'> 00523 <p align=center style='text-align:center'>-sp</p> 00524 </td> 00525 <td width=99 style='width:74.15pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.65pt'> 00526 <p align=center style='text-align:center'>cpsr</p> 00527 </td> 00528 <td width=87 style='width:65.55pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.65pt'> 00529 <p align=center style='text-align:center'>cpcr</p> 00530 </td> 00531 <td width=82 style='width:61.3pt;padding:0cm 5.4pt 0cm 5.4pt;height:19.65pt'> 00532 <p align=center style='text-align:center'>z</p> 00533 </td> 00534 </tr> 00535 <tr style='height:11.0pt'> 00536 <td width=66 style='width:49.65pt;padding:0cm 5.4pt 0cm 5.4pt;height:11.0pt'> 00537 <p align=center style='text-align:center'>0</p> 00538 </td> 00539 <td width=99 style='width:74.15pt;padding:0cm 5.4pt 0cm 5.4pt;height:11.0pt'> 00540 <p align=center style='text-align:center'>0</p> 00541 </td> 00542 <td width=87 style='width:65.55pt;padding:0cm 5.4pt 0cm 5.4pt;height:11.0pt'> 00543 <p align=center style='text-align:center'>0</p> 00544 </td> 00545 <td width=82 style='width:61.3pt;padding:0cm 5.4pt 0cm 5.4pt;height:11.0pt'> 00546 <p align=center style='text-align:center'>1</p> 00547 </td> 00548 </tr> 00549 </table> 00550 </div> 00551 <p align=center style='text-align:center'><span lang=EN-GB>where:</span></p> 00552 <p align=center style='text-align:center'><span lang=EN-GB>cy 00553 = cos Yaw ; sy = sin Yaw</span></p> 00554 <p align=center style='text-align:center'><span lang=EN-GB>cp 00555 = cos Pitch ; sp = sin Pitch</span></p> 00556 <p align=center style='text-align:center'><span lang=EN-GB>cr 00557 = cos Roll ; sr = sin Roll</span></p> 00558 </td> 00559 <td width=326 style='width:244.6pt;border-top:none;border-left:none; 00560 border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; 00561 padding:0cm 5.4pt 0cm 5.4pt;height:202.65pt'> 00562 <p align=center style='text-align:center'><span lang=EN-GB><img src="CPose3D.gif"></span></p> 00563 </td> 00564 </tr> 00565 </table> 00566 00567 </div> 00568 00569 * \sa CPose,CPoint 00570 */ 00571 class BASE_IMPEXP CPoseOrPoint : public mrpt::utils::CSerializable 00572 { 00573 // This must be added to any CSerializable derived class: 00574 DEFINE_VIRTUAL_SERIALIZABLE( CPoseOrPoint ) 00575 00576 protected: 00577 bool m_is3D; //!< Will be false for 2D points or poses, and true for 3D points or poses. 00578 double m_x, m_y, m_z; //!< The x y and z coordinates of the point or pose. 00579 00580 public: 00581 CPoseOrPoint() : m_is3D(), m_x(),m_y(),m_z() 00582 { } 00583 00584 inline double x() const { return m_x; } //!< Get the X coordinate 00585 inline double y() const { return m_y; } //!< Get the Y coordinate 00586 inline double z() const { return m_z; } //!< Get the Z coordinate 00587 00588 inline double &x() { return m_x; } //!< Get a reference to the X coordinate 00589 inline double &y() { return m_y; } //!< Get a reference to the Y coordinate 00590 inline double &z() { return m_z; } //!< Get a reference to the Z coordinate 00591 00592 virtual void x(const double x_) { m_x=x_; } //!< Set the X coordinate 00593 virtual void y(const double y_) { m_y=y_; } //!< Set the Y coordinate 00594 virtual void z(const double z_) { m_z=z_; } //!< Set the Z coordinate 00595 00596 virtual void x_incr(const double Ax) { m_x+=Ax; } //!< Increment the X coordinate 00597 virtual void y_incr(const double Ay) { m_y+=Ay; } //!< Increment the Y coordinate 00598 virtual void z_incr(const double Az) { m_z+=Az; } //!< Increment the Z coordinate 00599 00600 /** Return true for poses or points with a Z component, false otherwise. 00601 */ 00602 inline bool is3DPoseOrPoint() const { return m_is3D; } 00603 00604 /** Returns the euclidean distance to another pose/point: 00605 */ 00606 inline double distanceTo(const CPoseOrPoint &b) const 00607 { 00608 if (m_is3D || b.m_is3D) 00609 return sqrt(square(m_x-b.m_x) + square(m_y-b.m_y) + square(m_z-b.m_z)); 00610 else return sqrt(square(m_x-b.m_x) + square(m_y-b.m_y)); 00611 } 00612 00613 /** Returns the euclidean distance to another pose/point: 00614 */ 00615 inline double distanceTo(const mrpt::math::TPoint3D &b) const 00616 { 00617 if (m_is3D) 00618 return sqrt(square(m_x-b.x) + square(m_y-b.y) + square(m_z-b.z)); 00619 else return sqrt(square(m_x-b.x) + square(m_y-b.y)); 00620 } 00621 00622 /** Returns the squared euclidean distance to another pose/point: 00623 */ 00624 inline double sqrDistanceTo(const CPoseOrPoint &b) const 00625 { 00626 if (m_is3D || b.m_is3D) 00627 return square(m_x-b.m_x) + square(m_y-b.m_y) + square(m_z-b.m_z); 00628 else return square(m_x-b.m_x) + square(m_y-b.m_y); 00629 } 00630 00631 /** Returns the euclidean norm of vector: \f$ ||\mathbf{x}|| = \sqrt{x^2_1+y^2_i+...} \f$ 00632 */ 00633 double norm() const; 00634 00635 /** Scalar multiplication. 00636 */ 00637 virtual void operator *=(const double s) = 0; 00638 00639 /** Return the pose or point as a 1xN vector with all the components (see derived classes for each implementation) */ 00640 virtual void getAsVector(vector_double &v) const = 0; 00641 00642 /** Return the pose or point as a 1xN vector with all the components (see derived classes for each implementation) */ 00643 vector_double getAsVectorVal() const 00644 { 00645 vector_double v; 00646 this->getAsVector(v); 00647 return v; 00648 } 00649 00650 /** Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (translation+orientation). 00651 * \sa getInverseHomogeneousMatrix 00652 */ 00653 CMatrixDouble44 getHomogeneousMatrixVal() const { 00654 CMatrixDouble44 m(UNINITIALIZED_MATRIX); 00655 getHomogeneousMatrix(m); 00656 return m; 00657 } 00658 00659 /** Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (translation+orientation). 00660 * \sa getHomogeneousMatrixVal, getInverseHomogeneousMatrix 00661 */ 00662 virtual void getHomogeneousMatrix(CMatrixDouble44 & out_HM ) const =0; 00663 00664 /** Returns a human-readable textual representation of the object (eg: "[0.02 1.04 -0.8]" ) 00665 * \sa fromString 00666 */ 00667 virtual void asString(std::string &s) const = 0; 00668 00669 /** Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0.8]" ) 00670 * \sa asString 00671 * \exception std::exception On invalid format 00672 */ 00673 virtual void fromString(const std::string &s) = 0; 00674 00675 00676 /** Returns the corresponding inverse homogeneous 00677 * transformation matrix for the point(translation), 00678 * or pose (translation+orientation). 00679 * \sa getHomogeneousMatrix 00680 */ 00681 void getInverseHomogeneousMatrix( math::CMatrixDouble44 &out_HM ) const; 00682 00683 /** Returns the 2D distance from this pose/point to another given by its coordinates: 00684 * \sa distance2DToSquare,distance3DTo 00685 */ 00686 inline double distance2DTo( double ax, double ay ) const { return sqrt( square(ax-m_x)+square(ay-m_y) ); } 00687 00688 /** Returns the 3D distance from this pose/point to another given by its coordinates: 00689 * \sa distance3DToSquare,distance2DTo 00690 */ 00691 inline double distance3DTo( double ax, double ay, double az ) const { return sqrt( square(ax-m_x)+square(ay-m_y)+square(az-m_z)); } 00692 00693 /** Returns the square of the 2D distance from this pose/point to another given by its coordinates: 00694 * \sa distance2DTo,distance3DToSquare 00695 */ 00696 inline double distance2DToSquare( double ax, double ay ) const { return square(ax-m_x)+square(ay-m_y); } 00697 00698 /** Returns the square of the the 3D distance from this pose/point to another given by its coordinates: 00699 * \sa distance3DTo,distance2DToSquare 00700 */ 00701 inline double distance3DToSquare( double ax, double ay, double az ) const { return square(ax-m_x)+square(ay-m_y)+square(az-m_z); } 00702 00703 }; // End of class def. 00704 00705 00706 } // End of namespace 00707 } // End of namespace 00708 00709 #endif
| Page generated by Doxygen 1.7.1 for MRPT 0.9.1 SVN:exported at Fri Aug 6 10:31:35 UTC 2010 |
