LieAlgebra_se3.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009-2013 CEA LIST (DIASI/LSI) <xde-support@saxifrage.cea.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_LGSM_LIE_ALGEBRA_se3_H
11 #define EIGEN_LGSM_LIE_ALGEBRA_se3_H
12 
13 /***********************************************************************************
14 * Definition/implementation of LieAlgebraBase<Matrix<Scalar, 6, 1>, Derived>
15 ************************************************************************************/
16 
28 template<class Derived>
29 class LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>
30  : public MatrixBase<Derived>
31 {
32 protected:
34  typedef MatrixBase<Derived> Base;
35 public:
36  // inherit MatrixBase interface
37  EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraBase)
38  // inherit operator= [XXX] inheriting Base::opertor= through warning C4522 with visual studio : multiple assignment operators specified
39  // EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebraBase)
40  // accessor needed for MatrixBase inheritance
42 
44  typedef Matrix<Scalar, 6, 1> BaseType;
46  typedef typename internal::traits<Derived>::Coefficients Coefficients;
48  typedef LieAlgebra<BaseType> PlainObject;
50  typedef LieAlgebraDual<BaseType> AlgebraDual;
52  typedef typename internal::traits<Derived>::Group Group;
54  typedef Matrix<Scalar, 6, 6> Matrix6;
55 
57  typedef Matrix<Scalar, 3, 1> Vector3;
59  typedef LieAlgebra<Matrix<Scalar, 3, 1> > so3Element;
60 
61 
63  EIGEN_STRONG_INLINE LieAlgebraBase& operator=(const LieAlgebraBase& other);
65  template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator=(const MatrixBase<OtherDerived>& other);
66 
68  template<class OtherDerived> PlainObject bracket(const LieAlgebraBase<BaseType, OtherDerived>& a) const;
71  inline Group exp(const Scalar precision = 1.e-6) const;
75  inline Matrix<Scalar, 6, 6> dexp() const;
76  /*
77  inline Map<so3Element> getso3Element(){ return Map<so3Element>(this->get()); }
78  inline const Map<so3Element> getso3Element() const {return Map<so3Element>(this->get()); }
79  inline VectorBlock<Derived, 3> getR3Element(){ return this->tail<3>(); }
80  inline const VectorBlock<Derived, 3> getR3Element() const { return this->tail<3>(); }*/
81 
83  inline Map<so3Element> getso3Element(){ return Map<so3Element>(this->derived().get().template head<3>().data()); }
85  inline Map<const so3Element> getso3Element() const {return Map<const so3Element>(this->derived().get().template head<3>().data()); }
87  inline Map<Vector3> getR3Element() { return Map<Vector3>(this->derived().get().template tail<3>().data()); }
89  inline Map<const Vector3> getR3Element() const { return Map<const Vector3>(this->derived().get().template tail<3>().data()); }
90 
92  Coefficients& get() { return derived().get(); }
94  const Coefficients& get() const { return derived().get(); }
95 };
96 
97 /***************************************************************
98  * Implementation of LieAlgebraBase<Array<Scalar, 6, 1> > methods
99  ***************************************************************/
100 
101 // assignation
102 template<class Derived>
105 {
106  this->get() = other.get();
107  return *this;
108 }
109 
110 template<class Derived>
111 template<class OtherDerived>
112 inline Derived&
113  LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::operator=(const MatrixBase<OtherDerived>& other)
114 {
115  this->get() = other;
116  return derived();
117 }
118 
119 
120 // bracket
121 template<class Derived>
122 template<class OtherDerived>
125  OtherDerived>& a) const
126 {
127  return PlainObject(this->getso3Element().cross(a.getso3Element()),
128  this->getso3Element().cross(a.getR3Element()) - a.getso3Element().cross(this->getR3Element()) );
129 }
130 /*
131 // adjoint
132 template<class Derived>
133 template<class OtherDerived>
134  typename LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived >::PlainObject
135  LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived >::adjoint(const LieAlgebraBase<Matrix<Scalar, 6, 1>,
136  OtherDerived>& a) const
137 {
138  return this->bracket(ang);
139 }*/
140 
141 // exp -> unrolling this expression could be 30% faster.
142 template<class Derived> inline
144  LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::exp(const Scalar precision) const
145 {
146  return Group(this->getso3Element().dexp().transpose() * this->getR3Element()
147  ,this->getso3Element().exp());
148 }
149 
150 // dexp -> unrolling this expression maybe faster
151 template<class Derived>
152 inline typename LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived >::Matrix6
153  LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::dexp() const
154 {
155  Matrix<Scalar, 6, 6> res;
156 
157  // gcc does not seem to like res.block<3,3>(0,0) = this->getso3Element().dexp();
158  res.template block<3,3>(0,0) = this->getso3Element().dexp();
159  res.template block<3,3>(3,3) = res.template block<3,3>(0,0);
160  res.template block<3,3>(0,3).setZero();
161  res.template block<3,3>(3,0) = this->getso3Element().d2exp(this->getR3Element());
162 
163  return res;
164 }
165 
166 
167 /*************************************************************************************
168 * Definition/implementation of LieAlgebraDualBase<Matrix<Scalar, 6, 1>, Derived>
169 **************************************************************************************/
170 
182 template<class Derived>
183 class LieAlgebraDualBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived> : public MatrixBase<Derived> {
184 protected:
186  typedef MatrixBase<Derived> Base;
187 public:
188  // inherit MatrixBase interface
189  EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraDualBase)
190  // inherit operator= [XXX] inheriting Base::opertor= through warning C4522 with visual studio : multiple assignment operators specified
191  // EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebraDualBase)
192  // accessor needed for MatrixBase inheritance
194 
196  typedef Matrix<Scalar, 6, 1> BaseType;
198  typedef typename internal::traits<Derived>::Coefficients Coefficients;
200  typedef LieAlgebraDual<BaseType> PlainObject;
202  typedef LieAlgebra<BaseType> Algebra;
203 
205  typedef Matrix<Scalar, 3, 1> Vector3;
207  typedef LieAlgebraDual<Matrix<Scalar, 3, 1> > so3Element;
208 
210  inline Map<so3Element> getso3Element(){ return Map<so3Element>(this->derived().get().template head<3>().data()); }
212  inline Map<const so3Element> getso3Element() const {return Map<const so3Element>(this->derived().get().template head<3>().data()); }
214  inline Map<Vector3> getR3Element() { return Map<Vector3>(this->derived().get().template tail<3>().data()); }
216  inline Map<const Vector3> getR3Element() const { return Map<const Vector3>(this->derived().get().template tail<3>().data()); }
217 
219  Coefficients& get() { return derived().get(); }
221  const Coefficients& get() const { return derived().get(); }
222 };
223 
224 /***************************************************************************
225 * Definition/implementation of LieAlgebra<Matrix<Scalar, 6, 1> >
226 ***************************************************************************/
227 
238 namespace internal {
239  template<typename Scalar>
240  struct traits<LieAlgebra<Matrix<Scalar, 6, 1> > >
241  : public traits<LieAlgebraBase<Matrix<Scalar, 6, 1>, LieAlgebra<Matrix<Scalar, 6, 1> > > >
242  {
243  typedef Matrix<Scalar, 6, 1> Coefficients;
245  };
246 
247  template<typename Scalar, int Options>
248  struct traits<Map<LieAlgebra<Matrix<Scalar, 6, 1> >, Options> >
249  : public traits<LieAlgebraDualBase<Matrix<Scalar, 6, 1>, LieAlgebraDual<Matrix<Scalar, 6, 1> > > >
250  {
251  typedef Map<Matrix<Scalar, 6, 1>, Options> Coefficients;
253  };
254 
255  template<typename Scalar, int Options>
256  struct traits<Map<const LieAlgebra<Matrix<Scalar, 6, 1> >, Options> >
257  : public traits<LieAlgebraDualBase<Matrix<Scalar, 6, 1>, LieAlgebraDual<Matrix<Scalar, 6, 1> > > >
258  {
259  typedef Map<const Matrix<Scalar, 6, 1>, Options> Coefficients;
261  };
262 
263 }
264 
265 template<typename _Scalar> class LieAlgebra<Matrix<_Scalar, 6, 1> > :
266  public LieAlgebraBase<Matrix<_Scalar, 6, 1>, LieAlgebra<Matrix<_Scalar, 6, 1> > >
267 {
268 protected:
271 public:
272  // inherit MatrixBase operator
273  EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebra)
274  // inherit assignement operator
275  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebra)
276 
278  typedef typename Base::BaseType BaseType;
280  typedef typename internal::traits<LieAlgebra<Matrix<Scalar, 6, 1> > >::Coefficients Coefficients;
281 
283  inline LieAlgebra() : m_coeffs() {}
285  inline LieAlgebra(const LieAlgebra& g) : m_coeffs(g.get() ) {}
287  inline LieAlgebra(const BaseType& g) : m_coeffs(g) {}
289  inline LieAlgebra(Scalar rx, Scalar ry, Scalar rz, Scalar vx, Scalar vy, Scalar vz) {
290  m_coeffs[0] = rx;
291  m_coeffs[1] = ry;
292  m_coeffs[2] = rz;
293  m_coeffs[3] = vx;
294  m_coeffs[4] = vy;
295  m_coeffs[5] = vz;
296  }
298  inline LieAlgebra(const typename Base::so3Element& r, const typename Base::Vector3& v) {
299  this->getR3Element() = v;
300  this->getso3Element() = r;
301  }
302 
304  Coefficients& get() { return m_coeffs; }
306  const Coefficients& get() const { return m_coeffs; }
307 
308 protected:
311 };
312 
313 /***************************************************************************
314 * Definition/implementation of LieAlgebraDual<Matrix<Scalar, 6, 1> >
315 ***************************************************************************/
316 
327 template<typename _Scalar> class LieAlgebraDual<Matrix<_Scalar, 6, 1> > :
328  public LieAlgebraDualBase<Matrix<_Scalar, 6, 1>, LieAlgebraDual<Matrix<_Scalar, 6, 1> > >
329 {
330 protected:
332 public:
333  // inherit MatrixBase operator
334  EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraDual)
335  // inherit assignement operator
336  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebraDual)
337 
338  typedef typename internal::traits<LieAlgebraDual<Matrix<Scalar, 6, 1> > >::Coefficients Coefficients;
339 
340  inline LieAlgebraDual() : m_coeffs() {}
341  inline LieAlgebraDual(const LieAlgebraDual& g) : m_coeffs(g.get() ) {}
342  inline LieAlgebraDual(const Matrix<Scalar, 6, 1>& g) : m_coeffs(g) {}
343  inline LieAlgebraDual(Scalar rx, Scalar ry, Scalar rz, Scalar vx, Scalar vy, Scalar vz) {
344  m_coeffs << rx, ry, rz, vx, vy, vz;
345  }
346  inline LieAlgebraDual(const typename Base::so3Element& r, const typename Base::Vector3& v) {
347  this->getR3Element() = v;
348  this->getso3Element() = r;
349  }
350 
351  inline Coefficients& get() { return m_coeffs; }
352  inline const Coefficients& get() const { return m_coeffs; }
353 
354 protected:
356 };
357 
358 #endif
Class describing an element of a Lie Algebra.
Definition: LieAlgebra.h:168
Coefficients & get()
LieAlgebraDual(Scalar rx, Scalar ry, Scalar rz, Scalar vx, Scalar vy, Scalar vz)
LieAlgebra(const typename Base::so3Element &r, const typename Base::Vector3 &v)
LieAlgebra(Scalar rx, Scalar ry, Scalar rz, Scalar vx, Scalar vy, Scalar vz)
LieAlgebraDual(const Matrix< Scalar, 6, 1 > &g)
const Derived & derived() const
Definition: LieAlgebra.h:68
LieAlgebraDualBase< Matrix< _Scalar, 6, 1 >, LieAlgebraDual< Matrix< _Scalar, 6, 1 > > > Base
Derived::LieGroup Group
Definition: LieAlgebra.h:55
LieAlgebraDual(const typename Base::so3Element &r, const typename Base::Vector3 &v)
Group exp(Scalar precision=1.e-6) const
internal::traits< LieAlgebraDual< Matrix< Scalar, 6, 1 > > >::Coefficients Coefficients
#define LIE_INHERIT_MATRIX_BASE(r, c)
Definition: Macros.h:13
LieAlgebraBase< Matrix< _Scalar, 6, 1 >, LieAlgebra< Matrix< _Scalar, 6, 1 > > > Base
Base class for all Lie Algebra class.
Definition: Displacement.h:139
Class describing an element of a Lie Group.
Definition: LieGroup.h:117
internal::traits< LieAlgebra< Matrix< Scalar, 6, 1 > > >::Coefficients Coefficients
Class describing an element of a Lie algebra dual.
Definition: LieAlgebra.h:216
PlainObject bracket(const LieAlgebraBase< BaseType, OtherDerived > &a) const
LieAlgebra< BaseType > PlainObject
Definition: LieAlgebra.h:51


lgsm
Author(s): Roberto Martín-Martín
autogenerated on Mon Jun 10 2019 14:05:58