Main MRPT website > C++ reference
MRPT logo
math_frwds.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-2014, 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 mrpt_math_forwddecls_H
10 #define mrpt_math_forwddecls_H
11 
12 #include <mrpt/config.h>
13 #include <mrpt/base/link_pragmas.h>
14 #include <cmath>
15 #include <cstdlib>
16 #include <algorithm>
17 #include <string>
18 
19 /*! \file math_frwds.h
20  * Forward declarations of all mrpt::math classes related to vectors, arrays and matrices.
21  * Many of the function implementations are in ops_matrices.h, others in ops_containers.h
22  */
23 
24 namespace mrpt
25 {
26  namespace utils
27  {
29  template<class T> inline T square(const T x);
30  }
31 
32  namespace system
33  {
34  std::string BASE_IMPEXP MRPT_getVersion();
35  }
36 
37  namespace poses
38  {
39  class CPoint2D;
40  class CPoint3D;
41  class CPose2D;
42  class CPose3D;
43  class CPose3DQuat;
44  }
45 
46  namespace math
47  {
48  struct TPoint2D;
49  struct TPoint3D;
50  struct TPose2D;
51  struct TPose3D;
52  struct TPose3DQuat;
53 
54  namespace detail
55  {
56  /** Internal resize which compiles to nothing on fixed-size matrices. */
57  template <typename MAT,int TypeSizeAtCompileTime>
58  struct TAuxResizer {
59  static inline void internal_resize(MAT &obj, size_t row, size_t col) { }
60  static inline void internal_resize(MAT &obj, size_t nsize) { }
61  };
62  template <typename MAT>
63  struct TAuxResizer<MAT,-1> {
64  static inline void internal_resize(MAT &obj, size_t row, size_t col) { obj.derived().conservativeResize(row,col); }
65  static inline void internal_resize(MAT &obj, size_t nsize) { obj.derived().conservativeResize(nsize); }
66  };
67  }
68 
69 
70  /*! Selection of the number format in CMatrixTemplate::saveToTextFile
71  */
73  {
74  MATRIX_FORMAT_ENG = 0, //!< engineering format '%e'
75  MATRIX_FORMAT_FIXED = 1, //!< fixed floating point '%f'
76  MATRIX_FORMAT_INT = 2 //!< intergers '%i'
77  };
78 
79  /** For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes), if it's not required
80  to fill it with zeros at the constructor to save time. */
82  {
84  };
85 
86  // ---------------- Forward declarations: Classes ----------------
87  template <class T> class CMatrixTemplate;
88  template <class T> class CMatrixTemplateObjects;
89 
90 #define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_) \
91  explicit inline _CLASS_( const mrpt::math::TPose2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
92  explicit inline _CLASS_( const mrpt::math::TPose3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
93  explicit inline _CLASS_( const mrpt::math::TPose3DQuat &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
94  explicit inline _CLASS_( const mrpt::math::TPoint2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
95  explicit inline _CLASS_( const mrpt::math::TPoint3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
96  explicit inline _CLASS_( const mrpt::poses::CPose2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
97  explicit inline _CLASS_( const mrpt::poses::CPose3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
98  explicit inline _CLASS_( const mrpt::poses::CPose3DQuat &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
99  explicit inline _CLASS_( const mrpt::poses::CPoint2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
100  explicit inline _CLASS_( const mrpt::poses::CPoint3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); }
101 
102 
103  template <class CONTAINER1,class CONTAINER2> void cumsum(const CONTAINER1 &in_data, CONTAINER2 &out_cumsum);
104 
105  template <class CONTAINER> inline typename CONTAINER::Scalar norm(const CONTAINER &v);
106  template <class CONTAINER> inline typename CONTAINER::Scalar norm_inf(const CONTAINER &v);
107 
108  template <class MAT_A,class SKEW_3VECTOR,class MAT_OUT> void multiply_A_skew3(const MAT_A &A,const SKEW_3VECTOR &v, MAT_OUT &out);
109  template <class SKEW_3VECTOR,class MAT_A,class MAT_OUT> void multiply_skew3_A(const SKEW_3VECTOR &v,const MAT_A &A, MAT_OUT &out);
110 
111  namespace detail
112  {
113  // Implemented in "lightweight_geom_data.cpp"
114  TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
115  TPoint3D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint3D &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
116  TPose2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPose2D &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
117  TPose3D BASE_IMPEXP lightFromPose(const mrpt::poses::CPose3D &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
118  TPose3DQuat BASE_IMPEXP lightFromPose(const mrpt::poses::CPose3DQuat &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
119 
120  template <class MATORG, class MATDEST>
121  void extractMatrix(
122  const MATORG &M,
123  const size_t first_row,
124  const size_t first_col,
125  MATDEST &outMat);
126  }
127 
128  /** Conversion of poses to MRPT containers (vector/matrix) */
129  template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPoint2D &p);
130  template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPoint3D &p);
131  template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose2D &p);
132  template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose3D &p);
133  template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose3DQuat &p);
134 
135  template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPoint2D &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
136  template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPoint3D &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
137  template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose2D &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
138  template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose3D &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
139  template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose3DQuat &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
140 
141 
142  // Vicinity classes ----------------------------------------------------
143  namespace detail {
144  /**
145  * The purpose of this class is to model traits for containers, so that they can be used as return values for the function CMatrixTemplate::getVicinity.
146  * This class is NOT defined for any base container, because correctness would not be guaranteed. Instead, each class must define its own specialization
147  * of the template, containing two functions:
148  * - static void initialize(container<T>,size_t N): must reserve space to allow at least the insertion of N*N elements, in a square fashion when appliable.
149  * - static void insertInContainer(container<T>,size_t r,size_t c,const T &): must insert the given element in the container. Whenever it's possible, it
150  * must insert it in the (r,c) coordinates.
151  * For linear containers, the vicinity functions are guaranteed to insert elements in order, i.e., starting from the top and reading from left to right.
152  */
153  template<typename T> class VicinityTraits;
154 
155  /**
156  * This huge template encapsulates a function to get the vicinity of an element, with maximum genericity. Although it's not meant to be called directly,
157  * every type defining the ASSERT_ENOUGHROOM assert and the get_unsafe method will work. The assert checks if the boundaries (r-N,r+N,c-N,c+N) fit in
158  * the matrix.
159  * The template parameters are the following:
160  * - MatrixType: the matrix or container base type, from which the vicinity is required.
161  * - T: the base type of the matrix or container.
162  * - ReturnType: the returning container type. The class VicinityTraits<ReturnType> must be completely defined.
163  * - D: the dimension of the vicinity. Current implementations are 4, 5, 8, 9, 12, 13, 20, 21, 24 and 25, although it's easy to implement new variants.
164  */
165  template<typename MatrixType,typename T,typename ReturnType,size_t D> struct getVicinity;
166 
167  }
168 
169  // Other forward decls:
170  template <class T> T wrapTo2Pi(T a);
171 
172 
173  } // End of namespace
174 } // End of namespace
175 
176 #endif
TConstructorFlags_Matrices
For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes)...
Definition: math_frwds.h:81
engineering format &#39;e&#39;
Definition: math_frwds.h:74
TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p)
Convert a pose into a light-weight structure (functional form, needed for forward declarations) ...
void multiply_A_skew3(const MAT_A &A, const SKEW_3VECTOR &v, MAT_OUT &out)
Only for vectors/arrays "v" of length3, compute out = A * Skew(v), where Skew(v) is the skew symmetri...
Definition: ops_matrices.h:229
static void internal_resize(MAT &obj, size_t row, size_t col)
Definition: math_frwds.h:59
static void internal_resize(MAT &obj, size_t nsize)
Definition: math_frwds.h:65
std::string BASE_IMPEXP MRPT_getVersion()
Returns a string describing the MRPT version including the SVN number.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:36
void extractMatrix(const MATORG &M, const size_t first_row, const size_t first_col, MATDEST &outMat)
Extract a submatrix - The output matrix must be set to the required size before call.
Definition: ops_matrices.h:270
The purpose of this class is to model traits for containers, so that they can be used as return value...
Definition: math_frwds.h:153
static void internal_resize(MAT &obj, size_t row, size_t col)
Definition: math_frwds.h:64
T wrapTo2Pi(T a)
Modifies the given angle to translate it into the [0,2pi[ range.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:44
TMatrixTextFileFormat
Definition: math_frwds.h:72
class BASE_IMPEXP CPose3DQuat
Definition: CPose3D.h:22
A class used to store a 2D point.
Definition: CPoint2D.h:35
A class used to store a 3D point.
Definition: CPoint3D.h:33
void cumsum(const CONTAINER1 &in_data, CONTAINER2 &out_cumsum)
intergers &#39;i&#39;
Definition: math_frwds.h:76
CONTAINER::Scalar norm_inf(const CONTAINER &v)
Internal resize which compiles to nothing on fixed-size matrices.
Definition: math_frwds.h:58
T square(const T x)
Inline function for the square of a number.
Definition: bits.h:158
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose.
Definition: CPose2D.h:35
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:71
CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPoint2D &p)
Conversion of poses to MRPT containers (vector/matrix)
static void internal_resize(MAT &obj, size_t nsize)
Definition: math_frwds.h:60
TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p)
Convert a pose into a light-weight structure (functional form, needed for forward declarations) ...
This huge template encapsulates a function to get the vicinity of an element, with maximum genericity...
Definition: math_frwds.h:165
void multiply_skew3_A(const SKEW_3VECTOR &v, const MAT_A &A, MAT_OUT &out)
Only for vectors/arrays "v" of length3, compute out = Skew(v) * A, where Skew(v) is the skew symmetri...
Definition: ops_matrices.h:248
fixed floating point &#39;f&#39;
Definition: math_frwds.h:75
CONTAINER::Scalar norm(const CONTAINER &v)



Page generated by Doxygen 1.8.14 for MRPT 1.1.0 SVN: at lun oct 28 00:54:49 CET 2019 Hosted on:
SourceForge.net Logo