Rigid Body Dynamics Library
rbdl_eigenmath.h
Go to the documentation of this file.
1 /*
2  * RBDL - Rigid Body Dynamics Library
3  * Copyright (c) 2011-2018 Martin Felis <martin@fysx.org>
4  *
5  * Licensed under the zlib license. See LICENSE for more details.
6  */
7 
8 #ifndef RBDL_EIGENMATH_H
9 #define RBDL_EIGENMATH_H
10 
11 /* Exporting templated symbols is tricky when using MSVC. The following lines
12  * causes the classes in this file not to be explicitly exported. Instead
13  * they are already implicitly exported.
14  */
15 #if defined(WIN32) && defined(rbdl_EXPORTS)
16 #define RBDL_TEMPLATE_DLLAPI
17 #else
18 #define RBDL_TEMPLATE_DLLAPI RBDL_DLLAPI
19 #endif
20 
22 {
23  public:
25 
26  template<typename OtherDerived>
27  Vector2_t(const Eigen::MatrixBase<OtherDerived>& other)
28  : Eigen::Vector2d(other)
29  {}
30 
31  template<typename OtherDerived>
32  Vector2_t& operator=(const Eigen::MatrixBase<OtherDerived>& other)
33  {
34  this->Base::operator=(other);
35  return *this;
36  }
37 
38  EIGEN_STRONG_INLINE Vector2_t()
39  {}
40 
41  EIGEN_STRONG_INLINE Vector2_t(
42  const double& v0, const double& v1
43  )
44  {
45  Base::_check_template_params();
46 
47  (*this) << v0, v1;
48  }
49 
50  void set(const double& v0, const double& v1)
51  {
52  Base::_check_template_params();
53 
54  (*this) << v0, v1;
55  }
56 };
57 
59 {
60  public:
62 
63  template<typename OtherDerived>
64  Vector3_t(const Eigen::MatrixBase<OtherDerived>& other)
65  : Eigen::Vector3d(other)
66  {}
67 
68  template<typename OtherDerived>
69  Vector3_t& operator=(const Eigen::MatrixBase<OtherDerived>& other)
70  {
71  this->Base::operator=(other);
72  return *this;
73  }
74 
75  EIGEN_STRONG_INLINE Vector3_t()
76  {}
77 
78  EIGEN_STRONG_INLINE Vector3_t(
79  const double& v0, const double& v1, const double& v2
80  )
81  {
82  Base::_check_template_params();
83 
84  (*this) << v0, v1, v2;
85  }
86 
87  void set(const double& v0, const double& v1, const double& v2)
88  {
89  Base::_check_template_params();
90 
91  (*this) << v0, v1, v2;
92  }
93 };
94 
96 {
97  public:
99 
100  template<typename OtherDerived>
101  Matrix3_t(const Eigen::MatrixBase<OtherDerived>& other)
102  : Eigen::Matrix3d(other)
103  {}
104 
105  template<typename OtherDerived>
106  Matrix3_t& operator=(const Eigen::MatrixBase<OtherDerived>& other)
107  {
108  this->Base::operator=(other);
109  return *this;
110  }
111 
112  EIGEN_STRONG_INLINE Matrix3_t()
113  {}
114 
115  EIGEN_STRONG_INLINE Matrix3_t(
116  const double& m00, const double& m01, const double& m02,
117  const double& m10, const double& m11, const double& m12,
118  const double& m20, const double& m21, const double& m22
119  )
120  {
121  Base::_check_template_params();
122 
123  (*this)
124  << m00, m01, m02,
125  m10, m11, m12,
126  m20, m21, m22
127  ;
128  }
129 };
130 
132 {
133  public:
135 
136  template<typename OtherDerived>
137  Vector4_t(const Eigen::MatrixBase<OtherDerived>& other)
138  : Eigen::Vector4d(other)
139  {}
140 
141  template<typename OtherDerived>
142  Vector4_t& operator=(const Eigen::MatrixBase<OtherDerived>& other)
143  {
144  this->Base::operator=(other);
145  return *this;
146  }
147 
148  EIGEN_STRONG_INLINE Vector4_t()
149  {}
150 
151  EIGEN_STRONG_INLINE Vector4_t(
152  const double& v0, const double& v1, const double& v2, const double& v3
153  )
154  {
155  Base::_check_template_params();
156 
157  (*this) << v0, v1, v2, v3;
158  }
159 
160  void set(const double& v0, const double& v1, const double& v2, const double& v3)
161  {
162  Base::_check_template_params();
163 
164  (*this) << v0, v1, v2, v3;
165  }
166 };
167 
168 class RBDL_TEMPLATE_DLLAPI SpatialVector_t : public Eigen::Matrix<double, 6, 1>
169 {
170  public:
171  typedef Eigen::Matrix<double, 6, 1> Base;
172 
173  template<typename OtherDerived>
174  SpatialVector_t(const Eigen::MatrixBase<OtherDerived>& other)
175  : Eigen::Matrix<double, 6, 1>(other)
176  {}
177 
178  template<typename OtherDerived>
179  SpatialVector_t& operator=(const Eigen::MatrixBase<OtherDerived>& other)
180  {
181  this->Base::operator=(other);
182  return *this;
183  }
184 
185  EIGEN_STRONG_INLINE SpatialVector_t()
186  {}
187 
188  EIGEN_STRONG_INLINE SpatialVector_t(
189  const double& v0, const double& v1, const double& v2,
190  const double& v3, const double& v4, const double& v5
191  )
192  {
193  Base::_check_template_params();
194 
195  (*this) << v0, v1, v2, v3, v4, v5;
196  }
197 
198  void set(
199  const double& v0, const double& v1, const double& v2,
200  const double& v3, const double& v4, const double& v5
201  )
202  {
203  Base::_check_template_params();
204 
205  (*this) << v0, v1, v2, v3, v4, v5;
206  }
207 };
208 
209 class RBDL_TEMPLATE_DLLAPI SpatialMatrix_t : public Eigen::Matrix<double, 6, 6>
210 {
211  public:
212  typedef Eigen::Matrix<double, 6, 6> Base;
213 
214  template<typename OtherDerived>
215  SpatialMatrix_t(const Eigen::MatrixBase<OtherDerived>& other)
216  : Eigen::Matrix<double, 6, 6>(other)
217  {}
218 
219  template<typename OtherDerived>
220  SpatialMatrix_t& operator=(const Eigen::MatrixBase<OtherDerived>& other)
221  {
222  this->Base::operator=(other);
223  return *this;
224  }
225 
226  EIGEN_STRONG_INLINE SpatialMatrix_t()
227  {}
228 
229  EIGEN_STRONG_INLINE SpatialMatrix_t(
230  const Scalar& m00, const Scalar& m01, const Scalar& m02, const Scalar& m03, const Scalar& m04, const Scalar& m05,
231  const Scalar& m10, const Scalar& m11, const Scalar& m12, const Scalar& m13, const Scalar& m14, const Scalar& m15,
232  const Scalar& m20, const Scalar& m21, const Scalar& m22, const Scalar& m23, const Scalar& m24, const Scalar& m25,
233  const Scalar& m30, const Scalar& m31, const Scalar& m32, const Scalar& m33, const Scalar& m34, const Scalar& m35,
234  const Scalar& m40, const Scalar& m41, const Scalar& m42, const Scalar& m43, const Scalar& m44, const Scalar& m45,
235  const Scalar& m50, const Scalar& m51, const Scalar& m52, const Scalar& m53, const Scalar& m54, const Scalar& m55
236  )
237  {
238  Base::_check_template_params();
239 
240  (*this)
241  << m00, m01, m02, m03, m04, m05
242  , m10, m11, m12, m13, m14, m15
243  , m20, m21, m22, m23, m24, m25
244  , m30, m31, m32, m33, m34, m35
245  , m40, m41, m42, m43, m44, m45
246  , m50, m51, m52, m53, m54, m55
247  ;
248  }
249 
250  void set(
251  const Scalar& m00, const Scalar& m01, const Scalar& m02, const Scalar& m03, const Scalar& m04, const Scalar& m05,
252  const Scalar& m10, const Scalar& m11, const Scalar& m12, const Scalar& m13, const Scalar& m14, const Scalar& m15,
253  const Scalar& m20, const Scalar& m21, const Scalar& m22, const Scalar& m23, const Scalar& m24, const Scalar& m25,
254  const Scalar& m30, const Scalar& m31, const Scalar& m32, const Scalar& m33, const Scalar& m34, const Scalar& m35,
255  const Scalar& m40, const Scalar& m41, const Scalar& m42, const Scalar& m43, const Scalar& m44, const Scalar& m45,
256  const Scalar& m50, const Scalar& m51, const Scalar& m52, const Scalar& m53, const Scalar& m54, const Scalar& m55
257  )
258  {
259  Base::_check_template_params();
260 
261  (*this)
262  << m00, m01, m02, m03, m04, m05
263  , m10, m11, m12, m13, m14, m15
264  , m20, m21, m22, m23, m24, m25
265  , m30, m31, m32, m33, m34, m35
266  , m40, m41, m42, m43, m44, m45
267  , m50, m51, m52, m53, m54, m55
268  ;
269  }
270 };
271 
272 /* _RBDL_EIGENMATH_H */
273 #endif
SpatialMatrix_t & operator=(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE Vector3_t()
SpatialVector_t & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Vector3_t & operator=(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE Vector3_t(const double &v0, const double &v1, const double &v2)
Matrix3_t(const Eigen::MatrixBase< OtherDerived > &other)
#define RBDL_TEMPLATE_DLLAPI
Vector3_t(const Eigen::MatrixBase< OtherDerived > &other)
Eigen::Vector3d Base
Vector2_t & operator=(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE SpatialMatrix_t()
SpatialVector_t(const Eigen::MatrixBase< OtherDerived > &other)
Eigen::Vector2d Base
Vector4_t & operator=(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE Matrix3_t()
Eigen::Matrix< double, 6, 1 > Base
Matrix3_t & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Vector2_t(const Eigen::MatrixBase< OtherDerived > &other)
EIGEN_STRONG_INLINE SpatialMatrix_t(const Scalar &m00, const Scalar &m01, const Scalar &m02, const Scalar &m03, const Scalar &m04, const Scalar &m05, const Scalar &m10, const Scalar &m11, const Scalar &m12, const Scalar &m13, const Scalar &m14, const Scalar &m15, const Scalar &m20, const Scalar &m21, const Scalar &m22, const Scalar &m23, const Scalar &m24, const Scalar &m25, const Scalar &m30, const Scalar &m31, const Scalar &m32, const Scalar &m33, const Scalar &m34, const Scalar &m35, const Scalar &m40, const Scalar &m41, const Scalar &m42, const Scalar &m43, const Scalar &m44, const Scalar &m45, const Scalar &m50, const Scalar &m51, const Scalar &m52, const Scalar &m53, const Scalar &m54, const Scalar &m55)
Vector4_t(const Eigen::MatrixBase< OtherDerived > &other)
Eigen::Vector4d Base
EIGEN_STRONG_INLINE Matrix3_t(const double &m00, const double &m01, const double &m02, const double &m10, const double &m11, const double &m12, const double &m20, const double &m21, const double &m22)
EIGEN_STRONG_INLINE Vector4_t(const double &v0, const double &v1, const double &v2, const double &v3)
EIGEN_STRONG_INLINE SpatialVector_t(const double &v0, const double &v1, const double &v2, const double &v3, const double &v4, const double &v5)
SpatialMatrix_t(const Eigen::MatrixBase< OtherDerived > &other)
Eigen::Matrix< double, 6, 6 > Base
EIGEN_STRONG_INLINE Vector2_t(const double &v0, const double &v1)
EIGEN_STRONG_INLINE Vector2_t()
EIGEN_STRONG_INLINE SpatialVector_t()
Eigen::Matrix3d Base
EIGEN_STRONG_INLINE Vector4_t()