Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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>
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
22namespace mrpt
23{
24 namespace utils
25 {
26 class CStream;
27 template<class T> inline T square(const T x);
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>
50 struct TAuxResizer {
51 static inline void internal_resize(MAT &, size_t , size_t ) { }
52 static inline void internal_resize(MAT &, size_t ) { }
53 };
54 template <typename MAT>
55 struct TAuxResizer<MAT,-1> {
56 static inline void internal_resize(MAT &obj, size_t row, size_t col) { obj.derived().conservativeResize(row,col); }
57 static inline void internal_resize(MAT &obj, size_t nsize) { obj.derived().conservativeResize(nsize); }
58 };
59 }
60
61
62 /*! Selection of the number format in CMatrixTemplate::saveToTextFile
63 */
65 {
66 MATRIX_FORMAT_ENG = 0, //!< engineering format '%e'
67 MATRIX_FORMAT_FIXED = 1, //!< fixed floating point '%f'
68 MATRIX_FORMAT_INT = 2 //!< intergers '%i'
69 };
70
71 /** For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes), if it's not required
72 to fill it with zeros at the constructor to save time. */
74 {
76 };
77
78 // ---------------- Forward declarations: Classes ----------------
79 template <class T> class CMatrixTemplate;
80 template <class T> class CMatrixTemplateObjects;
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
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
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.
Definition: CPose2D.h:37
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,...
Definition: CPose3DQuat.h:42
EIGEN_STRONG_INLINE Scalar norm_inf() const
Compute the norm-infinite of a vector ($f[ ||\mathbf{v}||_\infnty $f]), ie the maximum absolute value...
T wrapTo2Pi(T a)
Modifies the given angle to translate it into the [0,2pi[ range.
Definition: wrap2pi.h:40
std::string BASE_IMPEXP MRPT_getVersion()
Returns a string describing the MRPT version.
TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p)
Convert a pose into a light-weight structure (functional form, needed for forward declarations)
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
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
TConstructorFlags_Matrices
For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes),...
Definition: math_frwds.h:74
@ UNINITIALIZED_MATRIX
Definition: math_frwds.h:75
TMatrixTextFileFormat
Definition: math_frwds.h:65
@ MATRIX_FORMAT_ENG
engineering format 'e'
Definition: math_frwds.h:66
@ MATRIX_FORMAT_FIXED
fixed floating point 'f'
Definition: math_frwds.h:67
@ MATRIX_FORMAT_INT
intergers 'i'
Definition: math_frwds.h:68
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:150
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...
T square(const T x)
Inline function for the square of a number.
Definition: bits.h:113
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:84
CONTAINER::value_type element_t
Definition: math_frwds.h:85
Lightweight 2D point.
Lightweight 3D point.
Lightweight 2D pose.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
static void internal_resize(MAT &obj, size_t nsize)
Definition: math_frwds.h:57
static void internal_resize(MAT &obj, size_t row, size_t col)
Definition: math_frwds.h:56
Internal resize which compiles to nothing on fixed-size matrices.
Definition: math_frwds.h:50
static void internal_resize(MAT &, size_t)
Definition: math_frwds.h:52
static void internal_resize(MAT &, size_t, size_t)
Definition: math_frwds.h:51
This huge template encapsulates a function to get the vicinity of an element, with maximum genericity...
Definition: math_frwds.h:153



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Wed Mar 22 04:35:51 UTC 2023