Robotics Library  0.6.2
MotionVector.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef _RL_MATH_MOTIONVECTOR_H_
28 #define _RL_MATH_MOTIONVECTOR_H_
29 
30 #include <Eigen/Core>
31 
32 namespace rl
33 {
34  namespace math
35  {
36  namespace spatial
37  {
38  template< typename Scalar > class ForceVector;
39 
40  template< typename Scalar >
42  {
43  public:
44  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45 
46  typedef Scalar ScalarType;
47 
48  typedef typename ::Eigen::Matrix< Scalar, 6, 1 > MatrixType;
49 
50  typedef const MatrixType ConstMatrixType;
51 
52  typedef ::Eigen::Block< MatrixType, 3, 1 > AngularType;
53 
54  typedef const ::Eigen::Block< ConstMatrixType, 3, 1 > ConstAngularType;
55 
56  typedef ::Eigen::Block< MatrixType, 3, 1 > LinearType;
57 
58  typedef const ::Eigen::Block< ConstMatrixType, 3, 1 > ConstLinearType;
59 
61  {
62  }
63 
64  template< typename OtherDerived >
65  MotionVector(const ::Eigen::MatrixBase< OtherDerived >& other) :
66  data(other)
67  {
68  }
69 
70  virtual ~MotionVector()
71  {
72  }
73 
75  {
76  return data.template segment< 3 >(0);
77  }
78 
80  {
81  return data.template segment< 3 >(0);
82  }
83 
84  template< typename OtherScalar >
86 
87  MotionVector cross(const MotionVector& other) const
88  {
89  MotionVector res;
90  res.angular() = angular().cross(other.angular());
91  res.linear() = angular().cross(other.linear()) + linear().cross(other.angular());
92  return res;
93  }
94 
95  template< typename OtherScalar >
96  Scalar dot(const ForceVector< OtherScalar >& other) const;
97 
99  {
100  return data.template segment< 3 >(3);
101  }
102 
104  {
105  return data.template segment< 3 >(3);
106  }
107 
109  {
110  return data;
111  }
112 
113  template< typename OtherDerived >
114  MotionVector& operator=(const ::Eigen::MatrixBase< OtherDerived >& other)
115  {
116  data = other;
117  return *this;
118  }
119 
120  MotionVector operator+(const MotionVector& other) const
121  {
122  MotionVector res;
123  res.angular() = angular() + other.angular();
124  res.linear() = linear() + other.linear();
125  return res;
126  }
127 
128  MotionVector operator-(const MotionVector& other) const
129  {
130  MotionVector res;
131  res.angular() = angular() - other.angular();
132  res.linear() = linear() - other.linear();
133  return res;
134  }
135 
136  template< typename OtherScalar >
137  MotionVector operator*(const OtherScalar& other) const
138  {
139  MotionVector res;
140  res.angular() = angular() * other;
141  res.linear() = linear() * other;
142  return res;
143  }
144 
145  template< typename OtherScalar >
146  MotionVector operator/(const OtherScalar& other) const
147  {
148  MotionVector res;
149  res.angular() = angular() / other;
150  res.linear() = linear() / other;
151  return res;
152  }
153 
154  void setZero()
155  {
156  angular().setZero();
157  linear().setZero();
158  }
159 
160  protected:
161 
162  private:
164  };
165  }
166  }
167 }
168 
169 #endif // _RL_MATH_MOTIONVECTOR_H_
rl::math::spatial::MotionVector::LinearType
::Eigen::Block< MatrixType, 3, 1 > LinearType
Definition: MotionVector.h:56
rl::math::spatial::MotionVector::operator-
MotionVector operator-(const MotionVector &other) const
Definition: MotionVector.h:128
rl::math::spatial::MotionVector::ConstMatrixType
const MatrixType ConstMatrixType
Definition: MotionVector.h:50
rl::math::spatial::MotionVector::dot
Scalar dot(const ForceVector< OtherScalar > &other) const
Definition: MotionVector.hxx:52
rl::math::spatial::MotionVector::MatrixType
::Eigen::Matrix< Scalar, 6, 1 > MatrixType
Definition: MotionVector.h:48
rl::math::spatial::MotionVector::linear
LinearType linear()
Definition: MotionVector.h:98
rl::math::spatial::MotionVector::ConstLinearType
const ::Eigen::Block< ConstMatrixType, 3, 1 > ConstLinearType
Definition: MotionVector.h:58
rl::math::spatial::MotionVector::cross
ForceVector< OtherScalar > cross(const ForceVector< OtherScalar > &other) const
Definition: MotionVector.hxx:40
rl::math::spatial::MotionVector::operator=
MotionVector & operator=(const ::Eigen::MatrixBase< OtherDerived > &other)
Definition: MotionVector.h:114
rl::math::spatial::MotionVector::ScalarType
Scalar ScalarType
Definition: MotionVector.h:46
rl::math::spatial::MotionVector::cross
MotionVector cross(const MotionVector &other) const
Definition: MotionVector.h:87
rl::math::spatial::MotionVector::data
MatrixType data
Definition: MotionVector.h:163
rl::math::spatial::MotionVector::angular
ConstAngularType angular() const
Definition: MotionVector.h:79
rl::math::spatial::MotionVector::operator+
MotionVector operator+(const MotionVector &other) const
Definition: MotionVector.h:120
rl::math::spatial::MotionVector::ConstAngularType
const ::Eigen::Block< ConstMatrixType, 3, 1 > ConstAngularType
Definition: MotionVector.h:54
rl::math::spatial::MotionVector::linear
ConstLinearType linear() const
Definition: MotionVector.h:103
rl::math::spatial::MotionVector::angular
AngularType angular()
Definition: MotionVector.h:74
rl::math::ForceVector
spatial::ForceVector< Real > ForceVector
Definition: Spatial.h:53
rl::math::spatial::MotionVector::operator/
MotionVector operator/(const OtherScalar &other) const
Definition: MotionVector.h:146
rl::math::spatial::MotionVector::MotionVector
MotionVector()
Definition: MotionVector.h:60
rl::math::spatial::MotionVector::AngularType
::Eigen::Block< MatrixType, 3, 1 > AngularType
Definition: MotionVector.h:52
rl::math::spatial::MotionVector::setZero
void setZero()
Definition: MotionVector.h:154
rl::math::spatial::MotionVector::MotionVector
MotionVector(const ::Eigen::MatrixBase< OtherDerived > &other)
Definition: MotionVector.h:65
rl::math::spatial::MotionVector::operator*
MotionVector operator*(const OtherScalar &other) const
Definition: MotionVector.h:137
rl::math::spatial::MotionVector::~MotionVector
virtual ~MotionVector()
Definition: MotionVector.h:70
rl::math::spatial::ForceVector
Definition: ForceVector.h:43
rl::math::spatial::MotionVector::matrix
ConstMatrixType & matrix() const
Definition: MotionVector.h:108
rl::math::spatial::MotionVector
Definition: MotionVector.h:42
rl
Definition: Ati.cpp:35