Twist.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_TWIST_H
11 #define EIGEN_LGSM_LIE_TWIST_H
12 
13 /*******************************************************************************
14 * Definition/implementation of TwistBase
15 ********************************************************************************/
16 
28 namespace internal {
29  template<class Derived>
30  struct traits<TwistBase<Derived> > : traits<LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived> > {
31  };
32 }
33 
34 template<class Derived>
35 class TwistBase : public LieAlgebraBase<Matrix<typename internal::traits<Derived>::Scalar, 6, 1>, Derived>{
36 protected:
39 public:
40  // inherit MatrixBase interface
41  EIGEN_DENSE_PUBLIC_INTERFACE(TwistBase)
42  // inherit assignement operator
43  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(TwistBase)
44 
46  typedef typename Base::BaseType BaseType;
48  typedef typename internal::traits<Derived>::Coefficients Coefficients;
49 
51  inline Scalar rx() const { return this->getAngularVelocity().x(); }
53  inline Scalar ry() const { return this->getAngularVelocity().y(); }
55  inline Scalar rz() const { return this->getAngularVelocity().z(); }
57  inline Scalar vx() const { return this->getLinearVelocity().x(); }
59  inline Scalar vy() const { return this->getLinearVelocity().y(); }
61  inline Scalar vz() const { return this->getLinearVelocity().z(); }
62 
64  inline Scalar& rx() { return this->getAngularVelocity().x(); }
66  inline Scalar& ry() { return this->getAngularVelocity().y(); }
68  inline Scalar& rz() { return this->getAngularVelocity().z(); }
70  inline Scalar& vx() { return this->getLinearVelocity().x(); }
72  inline Scalar& vy() { return this->getLinearVelocity().y(); }
74  inline Scalar& vz() { return this->getLinearVelocity().z(); }
75 
77  typedef Matrix<Scalar, 3, 1> LinearVelocity;
80 
82  inline Map<AngularVelocity> getAngularVelocity(){ return Map<AngularVelocity>(this->derived().get().template head<3>().data()); }
84  inline Map<const AngularVelocity> getAngularVelocity() const {return Map<const AngularVelocity>(this->derived().get().template head<3>().data()); }
86  inline Map<LinearVelocity> getLinearVelocity() { return Map<LinearVelocity>(this->derived().get().template tail<3>().data()); }
88  inline Map<const LinearVelocity> getLinearVelocity() const { return Map<const LinearVelocity>(this->derived().get().template tail<3>().data()); }
89 
90  template<class RotationDerived> inline Twist<Scalar> changeFrame(const LieGroupBase<Quaternion<Scalar>, RotationDerived>&) const;
91 
92  template<class OtherDerived> inline Twist<Scalar> changePoint(const MatrixBase<OtherDerived>& point) const;
93 };
94 
95 
96 template<class Derived>
97 template<class RotationDerived>
98 inline Twist<typename internal::traits<TwistBase<Derived> >::Scalar> TwistBase<Derived>::changeFrame(const LieGroupBase<Quaternion<Scalar>, RotationDerived>& rot) const {
99  return Twist<Scalar>(rot*this->getAngularVelocity(),
100  rot*this->getLinearVelocity());
101 }
102 
103 template<class Derived>
104 template<class OtherDerived>
105 inline Twist<typename internal::traits<TwistBase<Derived> >::Scalar> TwistBase<Derived>::changePoint(const MatrixBase<OtherDerived>& point) const {
106  return Twist<Scalar>(this->getAngularVelocity(),
107  this->getLinearVelocity() + this->getAngularVelocity().cross(point) );
108 }
109 
110 /**************************
111  * Implementation of Twist
112  **************************/
113 
114 namespace internal {
115  template<typename Scalar>
116  struct traits<Twist<Scalar> >
117  : public traits<LieAlgebra<Matrix<Scalar, 6, 1> > >
118  {
120  };
121 
122  template<typename Scalar, int Options>
123  struct traits<Map<Twist<Scalar>, Options> >
124  : public traits<Map<LieAlgebra<Matrix<Scalar, 6, 1> >, Options > >
125  {
127  };
128 }
129 
140 template<typename _Scalar>
141 class Twist : public TwistBase<Twist<_Scalar> >{
142 protected:
144 public:
145  // inherit MatrixBase interface
146  EIGEN_DENSE_PUBLIC_INTERFACE(Twist)
147  // inherit assignement operator
148  EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Twist)
149 
151  typedef typename Base::BaseType BaseType;
153  typedef typename internal::traits<Twist>::Coefficients Coefficients;
154 
155 
157  inline Twist() : m_coeffs() {}
159  inline Twist(const Twist& g) : m_coeffs(g.get() ) {}
161  inline Twist(const BaseType& g) : m_coeffs(g) {}
163  inline Twist(Scalar rx, Scalar ry, Scalar rz, Scalar vx, Scalar vy, Scalar vz) {
164  m_coeffs[0] = rx;
165  m_coeffs[1] = ry;
166  m_coeffs[2] = rz;
167  m_coeffs[3] = vx;
168  m_coeffs[4] = vy;
169  m_coeffs[5] = vz;
170  }
172  template<typename OtherDerived>
173  EIGEN_STRONG_INLINE Twist(const MatrixBase<OtherDerived>& other)
174  : m_coeffs(other)
175  {
176  }
178  //template<typename OtherDerived>
179  //EIGEN_STRONG_INLINE Twist& operator=(const MatrixBase<OtherDerived>& other)
180  //{
181  // this->m_coeffs = other;
182  // return *this;
183  //}
185  template<class LinearVelocityDerived, class AngularVelocityDerived>
186  inline Twist(const LieAlgebraBase<Matrix<Scalar, 3, 1>, AngularVelocityDerived>& r, const MatrixBase<LinearVelocityDerived>& v) {
187  this->getLinearVelocity() = v;
188  this->getAngularVelocity() = r;
189  }
191  inline Twist(const typename Base::AngularVelocity& r, const typename Base::LinearVelocity& v) {
192  this->getLinearVelocity() = v;
193  this->getAngularVelocity() = r;
194  }
196  inline Coefficients& get() { return m_coeffs; }
198  inline const Coefficients& get() const { return m_coeffs; }
199 
200 protected:
203 };
204 
209 
210 /**************************************
211  * Implementation of Map<Twist>
212  **************************************/
213 
214 
226 template<typename _Scalar, int MapOptions, typename StrideType>
227 class Map<Twist<_Scalar>, MapOptions, StrideType> : public TwistBase<Map<Twist<_Scalar>, MapOptions, StrideType> >{
228  protected:
230  public:
231  EIGEN_DENSE_PUBLIC_INTERFACE(Map)
232  EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Map)
233  typedef typename internal::traits<Map>::Coefficients Coefficients;
234 
235  inline Map(const Twist<Scalar>& d) : m_coeffs(d.get()) {};
236  template<int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
237  inline Map(const Array<Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& g) : m_coeffs(g.data()) {};
238 
239  inline Map(Scalar* data) : m_coeffs(data) {};
240  inline Map(const Map& m) : m_coeffs(m.get()) {};
241 
242  inline Coefficients& get() { return m_coeffs; }
243  inline const Coefficients& get() const { return m_coeffs; }
244 
245  protected:
247 };
248 
249 #endif
250 
LieAlgebraBase< Matrix< typename internal::traits< Derived >::Scalar, 6, 1 >, Derived > Base
Definition: Twist.h:38
Base::BaseType BaseType
Definition: Twist.h:151
Base class describing a Twist.
Definition: Twist.h:35
Class describing an element of a Lie Algebra.
Definition: LieAlgebra.h:168
Twist(Scalar rx, Scalar ry, Scalar rz, Scalar vx, Scalar vy, Scalar vz)
Definition: Twist.h:163
Map< const LinearVelocity > getLinearVelocity() const
Definition: Twist.h:88
internal::traits< Map >::Coefficients Coefficients
Definition: Twist.h:233
Map(const Array< Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &g)
Definition: Twist.h:237
Map< AngularVelocity > getAngularVelocity()
Definition: Twist.h:82
Class describing a Twist.
Definition: Twist.h:141
Twist(const typename Base::AngularVelocity &r, const typename Base::LinearVelocity &v)
Definition: Twist.h:191
TwistBase< Twist< _Scalar > > Base
Definition: Twist.h:143
Map< LinearVelocity > getLinearVelocity()
Definition: Twist.h:86
Matrix< Scalar, 3, 1 > LinearVelocity
Definition: Twist.h:77
Scalar & rx()
Definition: Twist.h:64
Twist< float > Twistf
Definition: Twist.h:208
Matrix< internal::traits< Twist< _Scalar > >::Scalar, 6, 1 > BaseType
Definition: LieAlgebra.h:47
Scalar & ry()
Definition: Twist.h:66
Twist(const BaseType &g)
Definition: Twist.h:161
Coefficients m_coeffs
Definition: Twist.h:202
LieAlgebra< Matrix< Scalar, 3, 1 > > AngularVelocity
Definition: Twist.h:79
Scalar & rz()
Definition: Twist.h:68
Twist(const LieAlgebraBase< Matrix< Scalar, 3, 1 >, AngularVelocityDerived > &r, const MatrixBase< LinearVelocityDerived > &v)
Definition: Twist.h:186
Scalar & vx()
Definition: Twist.h:70
Scalar rz() const
Definition: Twist.h:55
Scalar ry() const
Definition: Twist.h:53
Twist< double > Twistd
Definition: Twist.h:206
Twist< Scalar > changePoint(const MatrixBase< OtherDerived > &point) const
Base class for all Lie Group class.
Definition: LieGroup.h:39
Scalar vx() const
Definition: Twist.h:57
Map< const AngularVelocity > getAngularVelocity() const
Definition: Twist.h:84
Scalar & vy()
Definition: Twist.h:72
Scalar vz() const
Definition: Twist.h:61
Twist(const Twist &g)
Definition: Twist.h:159
internal::traits< Twist >::Coefficients Coefficients
Definition: Twist.h:153
Base class for all Lie Algebra class.
Definition: Displacement.h:139
TwistBase< Map< Twist< _Scalar > > > Base
Definition: Twist.h:229
Scalar & vz()
Definition: Twist.h:74
EIGEN_STRONG_INLINE Twist(const MatrixBase< OtherDerived > &other)
Definition: Twist.h:173
Displacement< Scalar > Group
Definition: Twist.h:119
Scalar vy() const
Definition: Twist.h:59
Twist< Scalar > changeFrame(const LieGroupBase< Quaternion< Scalar >, RotationDerived > &) const


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