Main MRPT website > C++ reference for MRPT 1.9.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/poses/poses_frwds.h>
14 #include <string>
15 
16 /*! \file math_frwds.h
17  * Forward declarations of all mrpt::math classes related to vectors, arrays
18  * and matrices.
19  * Many of the function implementations are in ops_matrices.h, others in
20  * ops_containers.h
21  */
22 
23 namespace mrpt
24 {
25 namespace utils
26 {
27 class CStream;
28 }
29 
30 namespace system
31 {
33 }
34 
35 namespace math
36 {
37 struct TPoint2D;
38 struct TPoint3D;
39 struct TPose2D;
40 struct TPose3D;
41 struct TPose3DQuat;
42 
43 class CMatrix; // mrpt-binary-serializable matrix
44 class CMatrixD; // mrpt-binary-serializable matrix
45 
46 namespace detail
47 {
48 /** Internal resize which compiles to nothing on fixed-size matrices. */
49 template <typename MAT, int TypeSizeAtCompileTime>
51 {
52  static inline void internal_resize(MAT&, size_t, size_t) {}
53  static inline void internal_resize(MAT&, size_t) {}
54 };
55 template <typename MAT>
56 struct TAuxResizer<MAT, -1>
57 {
58  static inline void internal_resize(MAT& obj, size_t row, size_t col)
59  {
60  obj.derived().conservativeResize(row, col);
61  }
62  static inline void internal_resize(MAT& obj, size_t nsize)
63  {
64  obj.derived().conservativeResize(nsize);
65  }
66 };
67 }
68 
69 /*! Selection of the number format in CMatrixTemplate::saveToTextFile
70  */
72 {
73  /** engineering format '%e' */
75  /** fixed floating point '%f' */
77  /** intergers '%i' */
79 };
80 
81 /** For usage in one of the constructors of CMatrixFixedNumeric or
82  CMatrixTemplate (and derived classes), if it's not required
83  to fill it with zeros at the constructor to save time. */
85 {
87 };
88 
89 // ---------------- Forward declarations: Classes ----------------
90 template <class T>
91 class CMatrixTemplate;
92 template <class T>
93 class CMatrixTemplateObjects;
94 template <class T>
95 class CQuaternion;
96 
97 /** ContainerType<T>::element_t exposes the value of any STL or Eigen container.
98  * Default specialization works for STL and MRPT containers, there is another
99  * one for Eigen in <mrpt/math/eigen_frwds.h> */
100 template <typename CONTAINER>
102 {
103  typedef typename CONTAINER::value_type element_t;
104 };
105 
106 #define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_) \
107  explicit inline _CLASS_(const mrpt::math::TPose2D& p) \
108  { \
109  mrpt::math::containerFromPoseOrPoint(*this, p); \
110  } \
111  explicit inline _CLASS_(const mrpt::math::TPose3D& p) \
112  { \
113  mrpt::math::containerFromPoseOrPoint(*this, p); \
114  } \
115  explicit inline _CLASS_(const mrpt::math::TPose3DQuat& p) \
116  { \
117  mrpt::math::containerFromPoseOrPoint(*this, p); \
118  } \
119  explicit inline _CLASS_(const mrpt::math::TPoint2D& p) \
120  { \
121  mrpt::math::containerFromPoseOrPoint(*this, p); \
122  } \
123  explicit inline _CLASS_(const mrpt::math::TPoint3D& p) \
124  { \
125  mrpt::math::containerFromPoseOrPoint(*this, p); \
126  } \
127  explicit inline _CLASS_(const mrpt::poses::CPose2D& p) \
128  { \
129  mrpt::math::containerFromPoseOrPoint(*this, p); \
130  } \
131  explicit inline _CLASS_(const mrpt::poses::CPose3D& p) \
132  { \
133  mrpt::math::containerFromPoseOrPoint(*this, p); \
134  } \
135  explicit inline _CLASS_(const mrpt::poses::CPose3DQuat& p) \
136  { \
137  mrpt::math::containerFromPoseOrPoint(*this, p); \
138  } \
139  explicit inline _CLASS_(const mrpt::poses::CPoint2D& p) \
140  { \
141  mrpt::math::containerFromPoseOrPoint(*this, p); \
142  } \
143  explicit inline _CLASS_(const mrpt::poses::CPoint3D& p) \
144  { \
145  mrpt::math::containerFromPoseOrPoint(*this, p); \
146  }
147 
148 template <class CONTAINER1, class CONTAINER2>
149 void cumsum(const CONTAINER1& in_data, CONTAINER2& out_cumsum);
150 
151 template <class CONTAINER>
152 inline typename CONTAINER::Scalar norm(const CONTAINER& v);
153 template <class CONTAINER>
154 inline typename CONTAINER::Scalar norm_inf(const CONTAINER& v);
155 
156 template <class MAT_A, class SKEW_3VECTOR, class MAT_OUT>
157 void multiply_A_skew3(const MAT_A& A, const SKEW_3VECTOR& v, MAT_OUT& out);
158 template <class SKEW_3VECTOR, class MAT_A, class MAT_OUT>
159 void multiply_skew3_A(const SKEW_3VECTOR& v, const MAT_A& A, MAT_OUT& out);
160 
161 namespace detail
162 {
163 // Implemented in "lightweight_geom_data.cpp"
164 /** Convert a pose into a light-weight structure (functional form, needed for
165  * forward declarations) */
166 TPoint2D lightFromPose(const mrpt::poses::CPoint2D& p);
167 /** Convert a pose into a light-weight structure (functional form, needed for
168  * forward declarations) */
169 TPoint3D lightFromPose(const mrpt::poses::CPoint3D& p);
170 /** Convert a pose into a light-weight structure (functional form, needed for
171  * forward declarations) */
172 TPose2D lightFromPose(const mrpt::poses::CPose2D& p);
173 /** Convert a pose into a light-weight structure (functional form, needed for
174  * forward declarations) */
175 TPose3D lightFromPose(const mrpt::poses::CPose3D& p);
176 /** Convert a pose into a light-weight structure (functional form, needed for
177  * forward declarations) */
178 TPose3DQuat lightFromPose(const mrpt::poses::CPose3DQuat& p);
179 
180 template <class MATORG, class MATDEST>
181 void extractMatrix(
182  const MATORG& M, const size_t first_row, const size_t first_col,
183  MATDEST& outMat);
184 }
185 
186 /** Conversion of poses (TPose2D,TPoint2D,...,
187  * mrpt::poses::CPoint2D,CPose3D,...) to MRPT containers (vector/matrix) */
188 template <class CONTAINER, class POINT_OR_POSE>
189 CONTAINER& containerFromPoseOrPoint(CONTAINER& C, const POINT_OR_POSE& p);
190 
191 // Vicinity classes ----------------------------------------------------
192 namespace detail
193 {
194 /**
195  * The purpose of this class is to model traits for containers, so that they
196  * can be used as return values for the function CMatrixTemplate::getVicinity.
197  * This class is NOT defined for any base container, because correctness would
198  * not be guaranteed. Instead, each class must define its own specialization
199  * of the template, containing two functions:
200  * - static void initialize(container<T>,size_t N): must reserve space to allow
201  * at least the insertion of N*N elements, in a square fashion when appliable.
202  * - static void insertInContainer(container<T>,size_t r,size_t c,const T &):
203  * must insert the given element in the container. Whenever it's possible, it
204  * must insert it in the (r,c) coordinates.
205  * For linear containers, the vicinity functions are guaranteed to insert
206  * elements in order, i.e., starting from the top and reading from left to
207  * right.
208  */
209 template <typename T>
211 
212 /**
213  * This huge template encapsulates a function to get the vicinity of an
214  * element, with maximum genericity. Although it's not meant to be called
215  * directly,
216  * every type defining the ASSERT_ENOUGHROOM assert and the get_unsafe method
217  * will work. The assert checks if the boundaries (r-N,r+N,c-N,c+N) fit in
218  * the matrix.
219  * The template parameters are the following:
220  * - MatrixType: the matrix or container base type, from which the vicinity is
221  * required.
222  * - T: the base type of the matrix or container.
223  * - ReturnType: the returning container type. The class
224  * VicinityTraits<ReturnType> must be completely defined.
225  * - D: the dimension of the vicinity. Current implementations are 4, 5, 8, 9,
226  * 12, 13, 20, 21, 24 and 25, although it's easy to implement new variants.
227  */
228 template <typename MatrixType, typename T, typename ReturnType, size_t D>
229 struct getVicinity;
230 }
231 
232 // Other forward decls:
233 template <class T>
234 T wrapTo2Pi(T a);
235 
236 } // End of namespace
237 } // End of namespace
238 
239 #endif
double Scalar
Definition: KmUtils.h:44
The purpose of this class is to model traits for containers, so that they can be used as return value...
Definition: math_frwds.h:210
A class used to store a 2D point.
Definition: CPoint2D.h:37
A class used to store a 3D point.
Definition: CPoint3D.h:33
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:41
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:89
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
Definition: CPose3DQuat.h:49
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
GLenum GLenum GLvoid * row
Definition: glext.h:3576
const GLdouble * v
Definition: glext.h:3678
GLfloat GLfloat p
Definition: glext.h:6305
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLsizei const GLchar ** string
Definition: glext.h:4101
T wrapTo2Pi(T a)
Modifies the given angle to translate it into the [0,2pi[ range.
Definition: wrap2pi.h:41
std::string MRPT_getVersion()
Returns a string describing the MRPT version.
Definition: os.cpp:184
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:215
TPoint2D lightFromPose(const mrpt::poses::CPoint2D &p)
Convert a pose into a light-weight structure (functional form, needed for forward declarations)
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:190
TConstructorFlags_Matrices
For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes),...
Definition: math_frwds.h:85
@ UNINITIALIZED_MATRIX
Definition: math_frwds.h:86
CONTAINER::Scalar norm_inf(const CONTAINER &v)
TMatrixTextFileFormat
Definition: math_frwds.h:72
@ MATRIX_FORMAT_ENG
engineering format 'e'
Definition: math_frwds.h:74
@ MATRIX_FORMAT_FIXED
fixed floating point 'f'
Definition: math_frwds.h:76
@ MATRIX_FORMAT_INT
intergers 'i'
Definition: math_frwds.h:78
CONTAINER::Scalar norm(const CONTAINER &v)
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:166
void cumsum(const CONTAINER1 &in_data, CONTAINER2 &out_cumsum)
CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const POINT_OR_POSE &p)
Conversion of poses (TPose2D,TPoint2D,..., mrpt::poses::CPoint2D,CPose3D,...) to MRPT containers (vec...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
ContainerType<T>::element_t exposes the value of any STL or Eigen container.
Definition: math_frwds.h:102
CONTAINER::value_type element_t
Definition: math_frwds.h:103
static void internal_resize(MAT &obj, size_t row, size_t col)
Definition: math_frwds.h:58
static void internal_resize(MAT &obj, size_t nsize)
Definition: math_frwds.h:62
Internal resize which compiles to nothing on fixed-size matrices.
Definition: math_frwds.h:51
static void internal_resize(MAT &, size_t)
Definition: math_frwds.h:53
static void internal_resize(MAT &, size_t, size_t)
Definition: math_frwds.h:52
This huge template encapsulates a function to get the vicinity of an element, with maximum genericity...
Definition: math_frwds.h:229



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 63ea9d1f1 Thu Nov 23 00:06:53 2017 +0100 at mar 26 may 2026 12:19:29 CEST