18 #ifndef __se3_motion_dense_hpp__ 19 #define __se3_motion_dense_hpp__ 26 template<
typename Derived>
27 struct SE3GroupAction< MotionDense<Derived> >
29 typedef typename SE3GroupAction< Derived >::ReturnType ReturnType;
32 template<
typename Derived,
typename MotionDerived>
33 struct MotionAlgebraAction< MotionDense<Derived>, MotionDerived >
35 typedef typename MotionAlgebraAction< Derived, MotionDerived >::ReturnType ReturnType;
39 template<
typename Derived>
40 class MotionDense :
public MotionBase<Derived>
43 typedef MotionBase<Derived> Base;
44 MOTION_TYPEDEF_TPL(Derived);
45 typedef typename traits<Derived>::MotionRefType MotionRefType;
52 Derived & setZero() { linear().setZero(); angular().setZero();
return derived(); }
53 Derived & setRandom() { linear().setZero(); angular().setZero();
return derived(); }
55 ActionMatrixType toActionMatrix_impl()
const 58 X.template block <3,3> (ANGULAR, ANGULAR) = X.template block <3,3> (LINEAR, LINEAR) =
skew(angular());
59 X.template block <3,3> (LINEAR, ANGULAR) =
skew(linear());
60 X.template block <3,3> (ANGULAR, LINEAR).setZero();
65 ActionMatrixType toDualActionMatrix_impl()
const 68 X.template block <3,3> (ANGULAR, ANGULAR) = X.template block <3,3> (LINEAR, LINEAR) =
skew(angular());
69 X.template block <3,3> (ANGULAR, LINEAR) =
skew(linear());
70 X.template block <3,3> (LINEAR, ANGULAR).setZero();
76 bool isEqual_impl(
const MotionDense<D2> & other)
const 77 {
return linear() == other.linear() && angular() == other.angular(); }
80 bool isEqual_impl(
const MotionBase<D2> & other)
const 81 {
return other.derived() == derived(); }
85 Derived & operator=(
const MotionDense<D2> & other)
87 linear() = other.linear();
88 angular() = other.angular();
93 Derived & operator=(
const Eigen::MatrixBase<V6> & v)
95 EIGEN_STATIC_ASSERT_VECTOR_ONLY(V6); assert(v.size() == 6);
96 linear() = v.template segment<3>(LINEAR);
97 angular() = v.template segment<3>(ANGULAR);
101 MotionPlain operator-()
const {
return derived().__opposite__(); }
102 template<
typename M1>
103 MotionPlain operator+(
const MotionDense<M1> & v)
const {
return derived().__plus__(v.derived()); }
104 template<
typename M1>
105 MotionPlain operator-(
const MotionDense<M1> & v)
const {
return derived().__minus__(v.derived()); }
107 template<
typename M1>
108 Derived & operator+=(
const MotionDense<M1> & v) {
return derived().__pequ__(v.derived()); }
109 template<
typename M1>
110 Derived & operator+=(
const MotionBase<M1> & v)
111 { v.derived().addTo(derived());
return derived(); }
113 template<
typename M1>
114 Derived & operator-=(
const MotionDense<M1> & v) {
return derived().__mequ__(v.derived()); }
116 MotionPlain __opposite__()
const {
return MotionPlain(-linear(),-angular()); }
118 template<
typename M1>
119 MotionPlain __plus__(
const MotionDense<M1> & v)
const 120 {
return MotionPlain(linear()+v.linear(), angular()+v.angular()); }
122 template<
typename M1>
123 MotionPlain __minus__(
const MotionDense<M1> & v)
const 124 {
return MotionPlain(linear()-v.linear(), angular()-v.angular()); }
126 template<
typename M1>
127 Derived & __pequ__(
const MotionDense<M1> & v)
128 { linear() += v.linear(); angular() += v.angular();
return derived(); }
130 template<
typename M1>
131 Derived & __mequ__(
const MotionDense<M1> & v)
132 { linear() -= v.linear(); angular() -= v.angular();
return derived(); }
134 template<
typename OtherScalar>
135 MotionPlain __mult__(
const OtherScalar & alpha)
const 136 {
return MotionPlain(alpha*linear(),alpha*angular()); }
138 template<
typename OtherScalar>
139 MotionPlain __div__(
const OtherScalar & alpha)
const 140 {
return derived().__mult__((OtherScalar)(1)/alpha); }
142 template<
typename F1>
143 Scalar dot(
const ForceBase<F1> & phi)
const 144 {
return phi.linear().dot(linear()) + phi.angular().dot(angular()); }
147 typename internal::MotionAlgebraAction<D,Derived>::ReturnType cross_impl(
const D & d)
const 149 return d.motionAction(derived());
152 template<
typename M1,
typename M2>
153 void motionAction(
const MotionDense<M1> & v, MotionDense<M2> & mout)
const 155 mout.linear() = v.linear().cross(angular())+v.angular().cross(linear());
156 mout.angular() = v.angular().cross(angular());
159 template<
typename M1>
160 MotionPlain motionAction(
const MotionDense<M1> & v)
const 167 template<
typename M2>
168 bool isApprox(
const MotionDense<M2> & m2,
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 169 {
return derived().isApprox_impl(m2, prec);}
171 template<
typename D2>
172 bool isApprox_impl(
const MotionDense<D2> & m2,
const Scalar & prec = Eigen::NumTraits<Scalar>::dummy_precision())
const 174 return linear().isApprox(m2.linear(), prec) && angular().isApprox(m2.angular(), prec);
177 template<
typename S2,
int O2,
typename D2>
178 void se3Action_impl(
const SE3Tpl<S2,O2> & m, MotionDense<D2> & v)
const 180 v.angular() = m.rotation()*angular();
181 v.linear() = m.rotation()*linear() + m.translation().cross(v.angular());
184 template<
typename S2,
int O2>
185 MotionPlain se3Action_impl(
const SE3Tpl<S2,O2> & m)
const 188 se3Action_impl(m,res);
192 template<
typename S2,
int O2,
typename D2>
193 void se3ActionInverse_impl(
const SE3Tpl<S2,O2> & m, MotionDense<D2> & v)
const 195 v.linear() = m.rotation().transpose()*(linear()-m.translation().cross(angular()));
196 v.angular() = m.rotation().transpose()*angular();
199 template<
typename S2,
int O2>
200 MotionPlain se3ActionInverse_impl(
const SE3Tpl<S2,O2> & m)
const 203 se3ActionInverse_impl(m,res);
207 void disp_impl(std::ostream & os)
const 210 <<
" v = " << linear().transpose () << std::endl
211 <<
" w = " << angular().transpose () << std::endl;
215 MotionRefType
ref() {
return derived().ref(); }
220 template<
typename M1,
typename M2>
223 {
return v1.derived().cross(v2.derived()); }
225 template<
typename M1,
typename F1>
228 {
return v.derived().cross(f.derived()); }
230 template<
typename M1>
237 #endif // ifndef __se3_motion_dense_hpp__
void skew(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector, i.e. the antisymmetric matrix representation o...
Base interface for forces representation.