Main MRPT website > C++ reference for MRPT 1.5.9
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-2017, 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 <mrpt/poses/poses_frwds.h>
15 #include <string>
16 
17 /*! \file math_frwds.h
18  * Forward declarations of all mrpt::math classes related to vectors, arrays and matrices.
19  * Many of the function implementations are in ops_matrices.h, others in ops_containers.h
20  */
21 
22 namespace mrpt
23 {
24  namespace utils
25  {
26  class CStream;
27  }
28 
29  namespace system
30  {
32  }
33 
34  namespace math
35  {
36  struct TPoint2D;
37  struct TPoint3D;
38  struct TPose2D;
39  struct TPose3D;
40  struct TPose3DQuat;
41 
42  class CMatrix; // mrpt-binary-serializable matrix
43  class CMatrixD; // mrpt-binary-serializable matrix
44 
45  namespace detail
46  {
47  /** Internal resize which compiles to nothing on fixed-size matrices. */
48  template <typename MAT,int TypeSizeAtCompileTime>
49  struct TAuxResizer {
50  static inline void internal_resize(MAT &, size_t , size_t ) { }
51  static inline void internal_resize(MAT &, size_t ) { }
52  };
53  template <typename MAT>
54  struct TAuxResizer<MAT,-1> {
55  static inline void internal_resize(MAT &obj, size_t row, size_t col) { obj.derived().conservativeResize(row,col); }
56  static inline void internal_resize(MAT &obj, size_t nsize) { obj.derived().conservativeResize(nsize); }
57  };
58  }
59 
60 
61  /*! Selection of the number format in CMatrixTemplate::saveToTextFile
62  */
64  {
65  MATRIX_FORMAT_ENG = 0, //!< engineering format '%e'
66  MATRIX_FORMAT_FIXED = 1, //!< fixed floating point '%f'
67  MATRIX_FORMAT_INT = 2 //!< intergers '%i'
68  };
69 
70  /** For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes), if it's not required
71  to fill it with zeros at the constructor to save time. */
73  {
75  };
76 
77  // ---------------- Forward declarations: Classes ----------------
78  template <class T> class CMatrixTemplate;
79  template <class T> class CMatrixTemplateObjects;
80  template <class T> class CQuaternion;
81 
82  /** ContainerType<T>::element_t exposes the value of any STL or Eigen container.
83  * Default specialization works for STL and MRPT containers, there is another one for Eigen in <mrpt/math/eigen_frwds.h> */
84  template <typename CONTAINER> struct ContainerType {
85  typedef typename CONTAINER::value_type element_t;
86  };
87 
88 #define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_) \
89  explicit inline _CLASS_( const mrpt::math::TPose2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
90  explicit inline _CLASS_( const mrpt::math::TPose3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
91  explicit inline _CLASS_( const mrpt::math::TPose3DQuat &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
92  explicit inline _CLASS_( const mrpt::math::TPoint2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
93  explicit inline _CLASS_( const mrpt::math::TPoint3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
94  explicit inline _CLASS_( const mrpt::poses::CPose2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
95  explicit inline _CLASS_( const mrpt::poses::CPose3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
96  explicit inline _CLASS_( const mrpt::poses::CPose3DQuat &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
97  explicit inline _CLASS_( const mrpt::poses::CPoint2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
98  explicit inline _CLASS_( const mrpt::poses::CPoint3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); }
99 
100 
101  template <class CONTAINER1,class CONTAINER2> void cumsum(const CONTAINER1 &in_data, CONTAINER2 &out_cumsum);
102 
103  template <class CONTAINER> inline typename CONTAINER::Scalar norm(const CONTAINER &v);
104  template <class CONTAINER> inline typename CONTAINER::Scalar norm_inf(const CONTAINER &v);
105 
106  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);
107  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);
108 
109  namespace detail
110  {
111  // Implemented in "lightweight_geom_data.cpp"
112  TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
113  TPoint3D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint3D &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
114  TPose2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPose2D &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
115  TPose3D BASE_IMPEXP lightFromPose(const mrpt::poses::CPose3D &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
116  TPose3DQuat BASE_IMPEXP lightFromPose(const mrpt::poses::CPose3DQuat &p); //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
117 
118  template <class MATORG, class MATDEST>
119  void extractMatrix(
120  const MATORG &M,
121  const size_t first_row,
122  const size_t first_col,
123  MATDEST &outMat);
124  }
125 
126  /** Conversion of poses (TPose2D,TPoint2D,..., mrpt::poses::CPoint2D,CPose3D,...) to MRPT containers (vector/matrix) */
127  template <class CONTAINER,class POINT_OR_POSE>
128  CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const POINT_OR_POSE &p);
129 
130  // Vicinity classes ----------------------------------------------------
131  namespace detail {
132  /**
133  * 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.
134  * This class is NOT defined for any base container, because correctness would not be guaranteed. Instead, each class must define its own specialization
135  * of the template, containing two functions:
136  * - 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.
137  * - 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
138  * must insert it in the (r,c) coordinates.
139  * 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.
140  */
141  template<typename T> class VicinityTraits;
142 
143  /**
144  * 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,
145  * 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
146  * the matrix.
147  * The template parameters are the following:
148  * - MatrixType: the matrix or container base type, from which the vicinity is required.
149  * - T: the base type of the matrix or container.
150  * - ReturnType: the returning container type. The class VicinityTraits<ReturnType> must be completely defined.
151  * - 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.
152  */
153  template<typename MatrixType,typename T,typename ReturnType,size_t D> struct getVicinity;
154 
155  }
156 
157  // Other forward decls:
158  template <class T> T wrapTo2Pi(T a);
159 
160 
161  } // End of namespace
162 } // End of namespace
163 
164 #endif
TConstructorFlags_Matrices
For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes)...
Definition: math_frwds.h:72
TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p)
Convert a pose into a light-weight structure (functional form, needed for forward declarations) ...
engineering format &#39;e&#39;
Definition: math_frwds.h:65
static void internal_resize(MAT &, size_t)
Definition: math_frwds.h:51
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:150
GLsizei GLsizei GLuint * obj
Definition: glext.h:3902
CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const POINT_OR_POSE &p)
Conversion of poses (TPose2D,TPoint2D,..., mrpt::poses::CPoint2D,CPose3D,...) to MRPT containers (vec...
static void internal_resize(MAT &obj, size_t nsize)
Definition: math_frwds.h:56
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:191
The purpose of this class is to model traits for containers, so that they can be used as return value...
Definition: math_frwds.h:141
static void internal_resize(MAT &obj, size_t row, size_t col)
Definition: math_frwds.h:55
T wrapTo2Pi(T a)
Modifies the given angle to translate it into the [0,2pi[ range.
Definition: wrap2pi.h:40
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:41
TMatrixTextFileFormat
Definition: math_frwds.h:63
GLsizei const GLchar ** string
Definition: glext.h:3919
A class used to store a 2D point.
Definition: CPoint2D.h:36
A class used to store a 3D point.
Definition: CPoint3D.h:32
static void internal_resize(MAT &, size_t, size_t)
Definition: math_frwds.h:50
void cumsum(const CONTAINER1 &in_data, CONTAINER2 &out_cumsum)
intergers &#39;i&#39;
Definition: math_frwds.h:67
CONTAINER::Scalar norm_inf(const CONTAINER &v)
Internal resize which compiles to nothing on fixed-size matrices.
Definition: math_frwds.h:49
const GLdouble * v
Definition: glext.h:3603
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:36
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
GLenum GLenum GLvoid * row
Definition: glext.h:3533
CONTAINER::value_type element_t
Definition: math_frwds.h:85
This huge template encapsulates a function to get the vicinity of an element, with maximum genericity...
Definition: math_frwds.h:153
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:169
std::string BASE_IMPEXP MRPT_getVersion()
Returns a string describing the MRPT version.
Definition: os.cpp:183
double Scalar
Definition: KmUtils.h:41
GLubyte GLubyte GLubyte a
Definition: glext.h:5575
GLfloat GLfloat p
Definition: glext.h:5587
fixed floating point &#39;f&#39;
Definition: math_frwds.h:66
CONTAINER::Scalar norm(const CONTAINER &v)



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020