00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef EIGEN_LGSM_LIE_ALGEBRA_se3_H
00011 #define EIGEN_LGSM_LIE_ALGEBRA_se3_H
00012
00013
00014
00015
00016
00028 template<class Derived>
00029 class LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>
00030 : public MatrixBase<Derived>
00031 {
00032 protected:
00034 typedef MatrixBase<Derived> Base;
00035 public:
00036
00037 EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraBase)
00038
00039
00040
00041 LIE_INHERIT_MATRIX_BASE(6, 1)
00042
00044 typedef Matrix<Scalar, 6, 1> BaseType;
00046 typedef typename internal::traits<Derived>::Coefficients Coefficients;
00048 typedef LieAlgebra<BaseType> PlainObject;
00050 typedef LieAlgebraDual<BaseType> AlgebraDual;
00052 typedef typename internal::traits<Derived>::Group Group;
00054 typedef Matrix<Scalar, 6, 6> Matrix6;
00055
00057 typedef Matrix<Scalar, 3, 1> Vector3;
00059 typedef LieAlgebra<Matrix<Scalar, 3, 1> > so3Element;
00060
00061
00063 EIGEN_STRONG_INLINE LieAlgebraBase& operator=(const LieAlgebraBase& other);
00065 template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator=(const MatrixBase<OtherDerived>& other);
00066
00068 template<class OtherDerived> PlainObject bracket(const LieAlgebraBase<BaseType, OtherDerived>& a) const;
00071 inline Group exp(const Scalar precision = 1.e-6) const;
00075 inline Matrix<Scalar, 6, 6> dexp() const;
00076
00077
00078
00079
00080
00081
00083 inline Map<so3Element> getso3Element(){ return Map<so3Element>(this->derived().get().template head<3>().data()); }
00085 inline Map<const so3Element> getso3Element() const {return Map<const so3Element>(this->derived().get().template head<3>().data()); }
00087 inline Map<Vector3> getR3Element() { return Map<Vector3>(this->derived().get().template tail<3>().data()); }
00089 inline Map<const Vector3> getR3Element() const { return Map<const Vector3>(this->derived().get().template tail<3>().data()); }
00090
00092 Coefficients& get() { return derived().get(); }
00094 const Coefficients& get() const { return derived().get(); }
00095 };
00096
00097
00098
00099
00100
00101
00102 template<class Derived>
00103 inline LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>&
00104 LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::operator=(const LieAlgebraBase& other)
00105 {
00106 this->get() = other.get();
00107 return *this;
00108 }
00109
00110 template<class Derived>
00111 template<class OtherDerived>
00112 inline Derived&
00113 LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::operator=(const MatrixBase<OtherDerived>& other)
00114 {
00115 this->get() = other;
00116 return derived();
00117 }
00118
00119
00120
00121 template<class Derived>
00122 template<class OtherDerived>
00123 typename LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::PlainObject
00124 LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::bracket(const LieAlgebraBase<Matrix<Scalar, 6, 1>,
00125 OtherDerived>& a) const
00126 {
00127 return PlainObject(this->getso3Element().cross(a.getso3Element()),
00128 this->getso3Element().cross(a.getR3Element()) - a.getso3Element().cross(this->getR3Element()) );
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 template<class Derived> inline
00143 typename LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::Group
00144 LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::exp(const Scalar precision) const
00145 {
00146 return Group(this->getso3Element().dexp().transpose() * this->getR3Element()
00147 ,this->getso3Element().exp());
00148 }
00149
00150
00151 template<class Derived>
00152 inline typename LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived >::Matrix6
00153 LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>::dexp() const
00154 {
00155 Matrix<Scalar, 6, 6> res;
00156
00157
00158 res.template block<3,3>(0,0) = this->getso3Element().dexp();
00159 res.template block<3,3>(3,3) = res.template block<3,3>(0,0);
00160 res.template block<3,3>(0,3).setZero();
00161 res.template block<3,3>(3,0) = this->getso3Element().d2exp(this->getR3Element());
00162
00163 return res;
00164 }
00165
00166
00167
00168
00169
00170
00182 template<class Derived>
00183 class LieAlgebraDualBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived> : public MatrixBase<Derived> {
00184 protected:
00186 typedef MatrixBase<Derived> Base;
00187 public:
00188
00189 EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraDualBase)
00190
00191
00192
00193 LIE_INHERIT_MATRIX_BASE(6, 1)
00194
00196 typedef Matrix<Scalar, 6, 1> BaseType;
00198 typedef typename internal::traits<Derived>::Coefficients Coefficients;
00200 typedef LieAlgebraDual<BaseType> PlainObject;
00202 typedef LieAlgebra<BaseType> Algebra;
00203
00205 typedef Matrix<Scalar, 3, 1> Vector3;
00207 typedef LieAlgebraDual<Matrix<Scalar, 3, 1> > so3Element;
00208
00210 inline Map<so3Element> getso3Element(){ return Map<so3Element>(this->derived().get().template head<3>().data()); }
00212 inline Map<const so3Element> getso3Element() const {return Map<const so3Element>(this->derived().get().template head<3>().data()); }
00214 inline Map<Vector3> getR3Element() { return Map<Vector3>(this->derived().get().template tail<3>().data()); }
00216 inline Map<const Vector3> getR3Element() const { return Map<const Vector3>(this->derived().get().template tail<3>().data()); }
00217
00219 Coefficients& get() { return derived().get(); }
00221 const Coefficients& get() const { return derived().get(); }
00222 };
00223
00224
00225
00226
00227
00238 namespace internal {
00239 template<typename Scalar>
00240 struct traits<LieAlgebra<Matrix<Scalar, 6, 1> > >
00241 : public traits<LieAlgebraBase<Matrix<Scalar, 6, 1>, LieAlgebra<Matrix<Scalar, 6, 1> > > >
00242 {
00243 typedef Matrix<Scalar, 6, 1> Coefficients;
00244 typedef LieGroup<Array<Scalar, 7, 1> > Group;
00245 };
00246
00247 template<typename Scalar, int Options>
00248 struct traits<Map<LieAlgebra<Matrix<Scalar, 6, 1> >, Options> >
00249 : public traits<LieAlgebraDualBase<Matrix<Scalar, 6, 1>, LieAlgebraDual<Matrix<Scalar, 6, 1> > > >
00250 {
00251 typedef Map<Matrix<Scalar, 6, 1>, Options> Coefficients;
00252 typedef LieGroup<Array<Scalar, 7, 1> > Group;
00253 };
00254
00255 template<typename Scalar, int Options>
00256 struct traits<Map<const LieAlgebra<Matrix<Scalar, 6, 1> >, Options> >
00257 : public traits<LieAlgebraDualBase<Matrix<Scalar, 6, 1>, LieAlgebraDual<Matrix<Scalar, 6, 1> > > >
00258 {
00259 typedef Map<const Matrix<Scalar, 6, 1>, Options> Coefficients;
00260 typedef LieGroup<Array<Scalar, 7, 1> > Group;
00261 };
00262
00263 }
00264
00265 template<typename _Scalar> class LieAlgebra<Matrix<_Scalar, 6, 1> > :
00266 public LieAlgebraBase<Matrix<_Scalar, 6, 1>, LieAlgebra<Matrix<_Scalar, 6, 1> > >
00267 {
00268 protected:
00270 typedef LieAlgebraBase<Matrix<_Scalar, 6, 1>, LieAlgebra<Matrix<_Scalar, 6, 1> > > Base;
00271 public:
00272
00273 EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebra)
00274
00275 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebra)
00276
00278 typedef typename Base::BaseType BaseType;
00280 typedef typename internal::traits<LieAlgebra<Matrix<Scalar, 6, 1> > >::Coefficients Coefficients;
00281
00283 inline LieAlgebra() : m_coeffs() {}
00285 inline LieAlgebra(const LieAlgebra& g) : m_coeffs(g.get() ) {}
00287 inline LieAlgebra(const BaseType& g) : m_coeffs(g) {}
00289 inline LieAlgebra(Scalar rx, Scalar ry, Scalar rz, Scalar vx, Scalar vy, Scalar vz) {
00290 m_coeffs[0] = rx;
00291 m_coeffs[1] = ry;
00292 m_coeffs[2] = rz;
00293 m_coeffs[3] = vx;
00294 m_coeffs[4] = vy;
00295 m_coeffs[5] = vz;
00296 }
00298 inline LieAlgebra(const typename Base::so3Element& r, const typename Base::Vector3& v) {
00299 this->getR3Element() = v;
00300 this->getso3Element() = r;
00301 }
00302
00304 Coefficients& get() { return m_coeffs; }
00306 const Coefficients& get() const { return m_coeffs; }
00307
00308 protected:
00310 Coefficients m_coeffs;
00311 };
00312
00313
00314
00315
00316
00327 template<typename _Scalar> class LieAlgebraDual<Matrix<_Scalar, 6, 1> > :
00328 public LieAlgebraDualBase<Matrix<_Scalar, 6, 1>, LieAlgebraDual<Matrix<_Scalar, 6, 1> > >
00329 {
00330 protected:
00331 typedef LieAlgebraDualBase<Matrix<_Scalar, 6, 1>, LieAlgebraDual<Matrix<_Scalar, 6, 1> > > Base;
00332 public:
00333
00334 EIGEN_DENSE_PUBLIC_INTERFACE(LieAlgebraDual)
00335
00336 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(LieAlgebraDual)
00337
00338 typedef typename internal::traits<LieAlgebraDual<Matrix<Scalar, 6, 1> > >::Coefficients Coefficients;
00339
00340 inline LieAlgebraDual() : m_coeffs() {}
00341 inline LieAlgebraDual(const LieAlgebraDual& g) : m_coeffs(g.get() ) {}
00342 inline LieAlgebraDual(const Matrix<Scalar, 6, 1>& g) : m_coeffs(g) {}
00343 inline LieAlgebraDual(Scalar rx, Scalar ry, Scalar rz, Scalar vx, Scalar vy, Scalar vz) {
00344 m_coeffs << rx, ry, rz, vx, vy, vz;
00345 }
00346 inline LieAlgebraDual(const typename Base::so3Element& r, const typename Base::Vector3& v) {
00347 this->getR3Element() = v;
00348 this->getso3Element() = r;
00349 }
00350
00351 inline Coefficients& get() { return m_coeffs; }
00352 inline const Coefficients& get() const { return m_coeffs; }
00353
00354 protected:
00355 Coefficients m_coeffs;
00356 };
00357
00358 #endif