10 #ifndef EIGEN_SPATIAL_MOTION_BASE_H_
11 #define EIGEN_SPATIAL_MOTION_BASE_H_
13 #include "spatial_declarations.h"
17 template<
typename Derived>
22 typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind;
23 typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex;
24 typedef typename Eigen::internal::traits<Derived>::Scalar Scalar;
25 typedef typename Eigen::internal::packet_traits<Scalar>::type PacketScalar;
26 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar;
28 typedef Eigen::DenseBase<Derived> Base;
29 using Base::RowsAtCompileTime;
30 using Base::ColsAtCompileTime;
31 using Base::SizeAtCompileTime;
32 using Base::MaxRowsAtCompileTime;
33 using Base::MaxColsAtCompileTime;
34 using Base::MaxSizeAtCompileTime;
35 using Base::IsVectorAtCompileTime;
39 using Base::const_cast_derived;
45 using Base::lazyAssign;
47 using Base::operator+=;
48 using Base::operator-=;
49 using Base::operator*=;
50 using Base::operator/=;
52 typedef typename Base::CoeffReturnType CoeffReturnType;
53 typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType;
54 typedef typename Base::RowXpr RowXpr;
55 typedef typename Base::ColXpr ColXpr;
61 (Flags & Eigen::RowMajorBit ? Eigen::RowMajor : Eigen::ColMajor),
64 typedef Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<Scalar>,
67 typedef Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<Scalar>,
70 typedef Eigen::Block<const Eigen::CwiseNullaryOp<Eigen::internal::scalar_identity_op<Scalar>,
72 6, ColsAtCompileTime> BasisReturnType;
74 typedef Eigen::Block<Eigen::MatrixWrapper<Derived>, 3, ColsAtCompileTime> CartesianBlockType;
76 typedef const Eigen::Block<const Eigen::MatrixWrapper<const Derived>, 3,
77 ColsAtCompileTime> ConstCartesianBlockType;
79 template<
typename OtherDerived>
81 typedef typename Eigen::ScalarBinaryOpTraits<Scalar,
82 typename OtherDerived::Scalar>::ReturnType ScalarT;
88 typedef Eigen::CwiseUnaryOp<Eigen::internal::scalar_opposite_op<Scalar>,
89 const Derived> NegativeReturnType;
91 const NegativeReturnType operator-()
const;
93 template<
class NewType>
95 typedef typename Eigen::internal::cast_return_type<Derived,
96 const Eigen::CwiseUnaryOp<Eigen::internal::scalar_cast_op<Scalar, NewType>,
97 const Derived>>::type Type;
100 template<
typename NewType>
101 typename CastXpr<NewType>::Type cast()
const;
103 template<
typename CustomUnaryOp>
104 inline const Eigen::CwiseUnaryOp<CustomUnaryOp, const Derived>
105 unaryExpr(
const CustomUnaryOp& func = CustomUnaryOp())
const;
107 template<
typename CustomViewOp>
108 inline const Eigen::CwiseUnaryView<CustomViewOp, const Derived>
109 unaryViewExpr(
const CustomViewOp& func = CustomViewOp())
const;
112 template<
typename OtherDerived>
114 typedef Eigen::CwiseBinaryOp<Eigen::internal::scalar_difference_op<Scalar,
115 typename OtherDerived::Scalar>,
116 const Derived,
const OtherDerived> DifferenceType;
117 typedef Eigen::CwiseBinaryOp<Eigen::internal::scalar_sum_op<Scalar,
118 typename OtherDerived::Scalar>,
119 const Derived,
const OtherDerived> SumType;
123 template<
typename OtherDerived>
124 const typename BinaryOpTraits<OtherDerived>::DifferenceType
128 template<
typename OtherDerived>
129 inline const typename BinaryOpTraits<OtherDerived>::SumType
134 typedef typename Eigen::ScalarBinaryOpTraits<Scalar, T,
135 Eigen::internal::scalar_product_op<Scalar, T>> RightProduct;
136 typedef typename Eigen::ScalarBinaryOpTraits<T, Scalar,
137 Eigen::internal::scalar_product_op<T, Scalar>> LeftProduct;
138 typedef typename Eigen::ScalarBinaryOpTraits<Scalar, T,
139 Eigen::internal::scalar_product_op<Scalar, T>> RightQuotient;
144 Eigen::CwiseBinaryOp<
145 Eigen::internal::scalar_product_op<
147 typename Eigen::internal::promote_scalar_arg<Scalar, T,
148 Eigen::internal::has_ReturnType<typename ScalarOpTraits<T>::RightProduct>::value>::type>,
150 const typename Eigen::internal::plain_constant_type<
152 typename Eigen::internal::promote_scalar_arg<Scalar, T,
153 Eigen::internal::has_ReturnType<typename ScalarOpTraits<T>::RightProduct>::value>::type>::type>
154 operator*(
const T& scalar)
const;
161 Eigen::CwiseBinaryOp<
162 Eigen::internal::scalar_quotient_op<
164 typename Eigen::internal::promote_scalar_arg<Scalar, T,
165 Eigen::internal::has_ReturnType<typename ScalarOpTraits<T>::RightQuotient>::value>::type>,
167 const typename Eigen::internal::plain_constant_type<
169 typename Eigen::internal::promote_scalar_arg<Scalar, T,
170 Eigen::internal::has_ReturnType<typename ScalarOpTraits<T>::RightQuotient>::value>::type>::type>
171 operator/(
const T& scalar)
const;
173 template<
typename CustomBinaryOp,
typename OtherDerived>
174 inline const Eigen::CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>
176 const CustomBinaryOp& func = CustomBinaryOp())
const;
180 template <
typename OtherDerived>
181 Derived& operator=(
const Eigen::DenseBase<OtherDerived>& other);
183 template <
typename OtherDerived>
184 Derived& operator=(
const Eigen::EigenBase<OtherDerived>& other);
186 template<
typename OtherDerived>
187 Derived& operator=(
const Eigen::ReturnByValue<OtherDerived>& other);
189 template<
typename OtherDerived>
192 template<
typename OtherDerived>
195 template<
typename OtherDerived>
198 template<
typename OtherDerived>
201 template<
typename OtherDerived>
202 const Eigen::Product<Derived, OtherDerived>
205 template<
typename OtherDerived>
207 operator*(
const Eigen::MatrixBase<OtherDerived>& other)
const;
209 template<
typename OtherDerived>
212 template<
typename CustomNullaryOp>
213 static const Eigen::CwiseNullaryOp<CustomNullaryOp, PlainObject>
214 NullaryExpr(Eigen::Index rows, Eigen::Index cols,
const CustomNullaryOp& func);
216 template<
typename CustomNullaryOp>
217 static const Eigen::CwiseNullaryOp<CustomNullaryOp, PlainObject>
218 NullaryExpr(Eigen::Index cols,
const CustomNullaryOp& func);
220 template<
typename CustomNullaryOp>
221 static const Eigen::CwiseNullaryOp<CustomNullaryOp, PlainObject>
222 NullaryExpr(
const CustomNullaryOp& func);
224 static const ConstantReturnType Constant(Eigen::Index cols,
const Scalar& value);
225 static const ConstantReturnType Constant(
const Scalar& value);
226 static const ConstantReturnType Zero(Eigen::Index cols);
227 static const ConstantReturnType Zero();
228 static const ConstantReturnType Ones(Eigen::Index cols);
229 static const ConstantReturnType Ones();
231 static const IdentityReturnType Identity();
232 static const IdentityReturnType Identity(Eigen::Index cols);
233 static const BasisReturnType Unit(Eigen::Index i);
234 static const BasisReturnType UnitLinX();
235 static const BasisReturnType UnitLinY();
236 static const BasisReturnType UnitLinZ();
237 static const BasisReturnType UnitAngX();
238 static const BasisReturnType UnitAngY();
239 static const BasisReturnType UnitAngZ();
241 Derived& setIdentity();
242 Derived& setIdentity(Eigen::Index cols);
243 Derived& setUnit(Eigen::Index i);
245 template<
typename OtherDerived>
246 typename SpatialOpTraits<OtherDerived>::ScalarT
249 template<
typename OtherDerived>
250 typename SpatialOpTraits<OtherDerived>::ScalarT
253 template<
typename OtherDerived>
257 template<
typename OtherDerived>
261 template<
typename OtherDerived>
264 template<
typename OtherDerived>
267 Eigen::MatrixWrapper<Derived> matrix();
268 const Eigen::MatrixWrapper<const Derived> matrix()
const;
270 Eigen::ArrayWrapper<Derived> array();
271 const Eigen::ArrayWrapper<const Derived> array()
const;
273 Eigen::Transpose<Eigen::MatrixWrapper<Derived>> transpose();
274 const Eigen::Transpose<Eigen::MatrixWrapper<const Derived>> transpose()
const;
276 CartesianBlockType linear();
277 ConstCartesianBlockType linear()
const;
279 CartesianBlockType angular();
280 ConstCartesianBlockType angular()
const;
287 template<
typename OtherDerived>
293 template<
typename Scalar,
int Dim,
typename Derived>
294 inline typename Derived::PlainObject
295 operator*(
const Eigen::Translation<Scalar, Dim>& T,
const SpatialMotionBase<Derived>& m) {
296 static_assert(Dim == 3,
"YOU_CAN_ONLY_APPLY_3D_TRANSFORMS_TO_SPATIAL_MOTIONS");
297 typename Derived::PlainObject result = m;
298 result.template topRows<3>() -= m.matrix().template bottomRows<3>().colwise().cross(T.translation());
302 template<
typename Scalar,
int Dim,
int Mode,
int Options,
typename Derived>
303 inline typename Derived::PlainObject
304 operator*(
const Eigen::Transform<Scalar, Dim, Mode, Options>& T,
const SpatialMotionBase<Derived>& m) {
305 static_assert(Dim == 3,
"YOU_CAN_ONLY_APPLY_3D_TRANSFORMS_TO_SPATIAL_MOTIONS");
306 static_assert(Mode ==
int(Eigen::Isometry),
"YOU_CAN_ONLY_APPLY_ISOMETRY_TRANSFORMS_TO_SPATIAL_MOTIONS");
308 typename Derived::PlainObject result = m;
309 result.template bottomRows<3>() = T.linear() * result.matrix().template bottomRows<3>();
310 result.template topRows<3>() = T.linear() * result.matrix().template topRows<3>() -
311 result.matrix().template bottomRows<3>().colwise().cross(T.translation());
316 template<
typename Derived>
317 inline const typename SpatialMotionBase<Derived>::NegativeReturnType
318 SpatialMotionBase<Derived>::operator-()
const {
319 return NegativeReturnType(derived());
322 template<
typename Derived>
323 template<
typename NewType>
324 inline typename SpatialMotionBase<Derived>::template CastXpr<NewType>::Type
325 SpatialMotionBase<Derived>::cast()
const {
326 return typename CastXpr<NewType>::Type(derived());
329 template<
typename Derived>
330 template<
typename CustomUnaryOp>
331 inline const Eigen::CwiseUnaryOp<CustomUnaryOp, const Derived>
332 SpatialMotionBase<Derived>::unaryExpr(
const CustomUnaryOp& func)
const {
333 return Eigen::CwiseUnaryOp<CustomUnaryOp, const Derived>(derived(), func);
336 template<
typename Derived>
337 template<
typename CustomViewOp>
338 inline const Eigen::CwiseUnaryView<CustomViewOp, const Derived>
339 SpatialMotionBase<Derived>::unaryViewExpr(
const CustomViewOp& func)
const {
340 return Eigen::CwiseUnaryView<CustomViewOp, const Derived>(derived(), func);
344 template<
typename Derived>
345 template<
typename OtherDerived>
346 inline const typename SpatialMotionBase<Derived>::template BinaryOpTraits<OtherDerived>::DifferenceType
347 SpatialMotionBase<Derived>::operator-(
const SpatialMotionBase<OtherDerived> &other)
const {
348 return typename BinaryOpTraits<OtherDerived>::DifferenceType(derived(), other.derived());
351 template<
typename Derived>
352 template<
typename OtherDerived>
353 inline const typename SpatialMotionBase<Derived>::template BinaryOpTraits<OtherDerived>::SumType
354 SpatialMotionBase<Derived>::operator+(
const SpatialMotionBase<OtherDerived> &other)
const {
355 return typename BinaryOpTraits<OtherDerived>::SumType(derived(), other.derived());
358 template<
typename Derived>
360 inline Eigen::CwiseBinaryOp<
361 Eigen::internal::scalar_product_op<
362 typename SpatialMotionBase<Derived>::Scalar,
363 typename Eigen::internal::promote_scalar_arg<typename SpatialMotionBase<Derived>::Scalar, T,
364 Eigen::internal::has_ReturnType<
365 typename SpatialMotionBase<Derived>::template ScalarOpTraits<T>::RightProduct>::value>::type>,
367 const typename Eigen::internal::plain_constant_type<
369 typename Eigen::internal::promote_scalar_arg<typename SpatialMotionBase<Derived>::Scalar, T,
370 Eigen::internal::has_ReturnType<
371 typename SpatialMotionBase<Derived>::template ScalarOpTraits<T>::RightProduct>::value>::type>::type>
372 SpatialMotionBase<Derived>::operator*(
const T& scalar)
const {
373 typedef typename Eigen::internal::promote_scalar_arg<Scalar, T,
374 Eigen::internal::has_ReturnType<typename ScalarOpTraits<T>::RightProduct>::value>::type PromotedT;
375 typedef typename Eigen::internal::plain_constant_type<Derived, PromotedT>::type PlainType;
376 typedef typename Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<Scalar, PromotedT>,
377 const Derived,
const PlainType> ReturnType;
378 typedef typename Eigen::internal::scalar_constant_op<PromotedT> ScalarOp;
379 return ReturnType(derived(), PlainType(derived().rows(), derived().cols(), ScalarOp(scalar)));
382 template<
typename T,
typename Derived>
383 inline Eigen::CwiseBinaryOp<
384 Eigen::internal::scalar_product_op<
385 typename Eigen::internal::promote_scalar_arg<typename SpatialMotionBase<Derived>::Scalar, T,
386 Eigen::internal::has_ReturnType<
387 typename SpatialMotionBase<Derived>::template ScalarOpTraits<T>::LeftProduct>::value>::type,
388 typename SpatialMotionBase<Derived>::Scalar>,
389 const typename Eigen::internal::plain_constant_type<
391 typename Eigen::internal::promote_scalar_arg<typename SpatialMotionBase<Derived>::Scalar, T,
392 Eigen::internal::has_ReturnType<
393 typename SpatialMotionBase<Derived>::template ScalarOpTraits<T>::LeftProduct>::value>::type>::type,
395 operator*(
const T& scalar,
const SpatialMotionBase<Derived>& m) {
396 typedef typename SpatialMotionBase<Derived>::template ScalarOpTraits<T> ScalarOpTraits;
397 typedef typename SpatialMotionBase<Derived>::Scalar Scalar;
399 typedef typename Eigen::internal::promote_scalar_arg<Scalar, T,
400 Eigen::internal::has_ReturnType<typename ScalarOpTraits::LeftProduct>::value>::type PromotedT;
401 typedef typename Eigen::internal::plain_constant_type<Derived, PromotedT>::type PlainType;
402 typedef typename Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<PromotedT, Scalar>,
403 const PlainType,
const Derived> ReturnType;
404 typedef typename Eigen::internal::scalar_constant_op<PromotedT> ScalarOp;
405 return ReturnType(PlainType(m.derived().rows(), m.derived().cols(), ScalarOp(scalar)), m.derived());
408 template<
typename Derived>
410 inline Eigen::CwiseBinaryOp<
411 Eigen::internal::scalar_quotient_op<
412 typename SpatialMotionBase<Derived>::Scalar,
413 typename Eigen::internal::promote_scalar_arg<typename SpatialMotionBase<Derived>::Scalar, T,
414 Eigen::internal::has_ReturnType<
415 typename SpatialMotionBase<Derived>::template ScalarOpTraits<T>::RightQuotient>::value>::type>,
417 const typename Eigen::internal::plain_constant_type<
419 typename Eigen::internal::promote_scalar_arg<typename SpatialMotionBase<Derived>::Scalar, T,
420 Eigen::internal::has_ReturnType<
421 typename SpatialMotionBase<Derived>::template ScalarOpTraits<T>::RightQuotient>::value>::type>::type>
422 SpatialMotionBase<Derived>::operator/(
const T& scalar)
const {
423 typedef typename Eigen::internal::promote_scalar_arg<Scalar, T,
424 Eigen::internal::has_ReturnType<typename ScalarOpTraits<T>::RightQuotient>::value>::type PromotedT;
425 typedef typename Eigen::internal::plain_constant_type<Derived, PromotedT>::type PlainType;
426 typedef typename Eigen::CwiseBinaryOp<Eigen::internal::scalar_quotient_op<Scalar, PromotedT>,
427 const Derived,
const PlainType> ReturnType;
428 typedef typename Eigen::internal::scalar_constant_op<PromotedT> ScalarOp;
429 return ReturnType(derived(), PlainType(derived().rows(), derived().cols(), ScalarOp(scalar)));
432 template<
typename Derived>
433 template<
typename CustomBinaryOp,
typename OtherDerived>
434 inline const Eigen::CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived>
435 SpatialMotionBase<Derived>::binaryExpr(
const SpatialMotionBase<OtherDerived> &other,
436 const CustomBinaryOp& func)
const {
437 return Eigen::CwiseBinaryOp<CustomBinaryOp,
const Derived,
438 const OtherDerived>(derived(), other.derived(), func);
442 template<
typename Derived>
443 inline Derived& SpatialMotionBase<Derived>::operator=(
const SpatialMotionBase& other) {
444 Eigen::internal::call_assignment(derived(), other.derived());
448 template<
typename Derived>
449 template<
typename OtherDerived>
450 inline Derived& SpatialMotionBase<Derived>::operator=(
const Eigen::DenseBase<OtherDerived>& other) {
451 Eigen::internal::call_assignment(derived(), other.derived());
455 template<
typename Derived>
456 template<
typename OtherDerived>
457 inline Derived& SpatialMotionBase<Derived>::operator=(
const Eigen::EigenBase<OtherDerived>& other) {
458 Eigen::internal::call_assignment(derived(), other.derived());
462 template<
typename Derived>
463 template<
typename OtherDerived>
464 inline Derived& SpatialMotionBase<Derived>::operator=(
const Eigen::ReturnByValue<OtherDerived>& other) {
465 other.derived().evalTo(derived());
470 template<
typename Derived>
471 template<
typename OtherDerived>
472 inline Derived& SpatialMotionBase<Derived>::operator+=(
const SpatialMotionBase<OtherDerived>& other) {
473 Eigen::internal::call_assignment(derived(), other.derived(),
474 Eigen::internal::add_assign_op<Scalar, typename OtherDerived::Scalar>());
478 template<
typename Derived>
479 template<
typename OtherDerived>
480 inline Derived& SpatialMotionBase<Derived>::operator+=(
const SpatialForceBase<OtherDerived>&) {
481 static_assert(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar)) == -1,
482 "YOU_CANNOT_ADD_SPATIAL_MOTION_AND_SPATIAL_FORCE_VECTORS");
486 template<
typename Derived>
487 template<
typename OtherDerived>
488 inline Derived& SpatialMotionBase<Derived>::operator-=(
const SpatialMotionBase<OtherDerived>& other) {
489 Eigen::internal::call_assignment(derived(), other.derived(),
490 Eigen::internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
494 template<
typename Derived>
495 template<
typename OtherDerived>
496 inline Derived& SpatialMotionBase<Derived>::operator-=(
const SpatialForceBase<OtherDerived>&) {
497 static_assert(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar)) == -1,
498 "YOU_CANNOT_ADD_SPATIAL_MOTION_AND_SPATIAL_FORCE_VECTORS");
502 template<
typename Derived>
503 template<
typename OtherDerived>
504 inline const Eigen::Product<Derived, OtherDerived>
505 SpatialMotionBase<Derived>::operator*(
const SpatialMotionBase<OtherDerived>&)
const {
506 static_assert(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar)) == -1,
507 "YOU_CANNOT_MULTIPLY_TWO_SPATIAL_MOTION_VECTORS");
510 template<
typename Derived>
511 template<
typename OtherDerived>
512 inline SpatialMotion<typename SpatialMotionBase<Derived>::template SpatialOpTraits<OtherDerived>::ScalarT,
513 OtherDerived::ColsAtCompileTime>
514 SpatialMotionBase<Derived>::operator*(
const Eigen::MatrixBase<OtherDerived>& other)
const {
515 static_assert(ColsAtCompileTime == Eigen::Dynamic ||
516 OtherDerived::RowsAtCompileTime == Eigen::Dynamic ||
517 int(ColsAtCompileTime) ==
int(OtherDerived::RowsAtCompileTime),
518 "INVALID_MATRIX_PRODUCT");
520 return Eigen::Product<Derived, OtherDerived, Eigen::LazyProduct>(derived(), other.derived());
524 template<
typename Derived>
525 template<
typename OtherDerived>
526 inline Derived& SpatialMotionBase<Derived>::operator*=(
const SpatialMotionBase<OtherDerived>&) {
527 static_assert(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar)) == -1,
528 "YOU_CANNOT_MULTIPLY_TWO_SPATIAL_MOTION_VECTORS");
532 template<
typename Derived>
533 template<
typename CustomNullaryOp>
534 inline const Eigen::CwiseNullaryOp<CustomNullaryOp,
535 typename SpatialMotionBase<Derived>::PlainObject>
536 SpatialMotionBase<Derived>::NullaryExpr(Eigen::Index rows, Eigen::Index cols,
537 const CustomNullaryOp& func) {
538 return Eigen::CwiseNullaryOp<CustomNullaryOp, PlainObject>(6, cols, func);
541 template<
typename Derived>
542 template<
typename CustomNullaryOp>
543 inline const Eigen::CwiseNullaryOp<CustomNullaryOp,
544 typename SpatialMotionBase<Derived>::PlainObject>
545 SpatialMotionBase<Derived>::NullaryExpr(Eigen::Index cols,
const CustomNullaryOp& func) {
546 return Eigen::CwiseNullaryOp<CustomNullaryOp, PlainObject>(6, cols, func);
549 template<
typename Derived>
550 template<
typename CustomNullaryOp>
551 inline const Eigen::CwiseNullaryOp<CustomNullaryOp,
552 typename SpatialMotionBase<Derived>::PlainObject>
553 SpatialMotionBase<Derived>::NullaryExpr(
const CustomNullaryOp& func) {
554 return Eigen::CwiseNullaryOp<CustomNullaryOp, PlainObject>(6, ColsAtCompileTime, func);
557 template<
typename Derived>
558 inline const typename SpatialMotionBase<Derived>::ConstantReturnType
559 SpatialMotionBase<Derived>::Constant(Eigen::Index cols,
const Scalar& value) {
560 return NullaryExpr(cols, Eigen::internal::scalar_constant_op<Scalar>(value));
563 template<
typename Derived>
564 inline const typename SpatialMotionBase<Derived>::ConstantReturnType
565 SpatialMotionBase<Derived>::Constant(
const Scalar& value) {
566 static_assert(ColsAtCompileTime != Eigen::Dynamic,
"MATRIX_MUST_BE_OF_FIXED_SIZE");
567 return NullaryExpr(ColsAtCompileTime, Eigen::internal::scalar_constant_op<Scalar>(value));
570 template<
typename Derived>
571 inline const typename SpatialMotionBase<Derived>::ConstantReturnType
572 SpatialMotionBase<Derived>::Zero(Eigen::Index cols) {
573 return Constant(cols, Scalar(0));
576 template<
typename Derived>
577 inline const typename SpatialMotionBase<Derived>::ConstantReturnType
578 SpatialMotionBase<Derived>::Zero() {
579 return Constant(Scalar(0));
582 template<
typename Derived>
583 inline const typename SpatialMotionBase<Derived>::ConstantReturnType
584 SpatialMotionBase<Derived>::Ones(Eigen::Index cols) {
585 return Constant(cols, Scalar(1));
588 template<
typename Derived>
589 inline const typename SpatialMotionBase<Derived>::ConstantReturnType
590 SpatialMotionBase<Derived>::Ones() {
591 return Constant(Scalar(1));
594 template<
typename Derived>
595 inline const typename SpatialMotionBase<Derived>::IdentityReturnType
596 SpatialMotionBase<Derived>::Identity() {
597 static_assert(ColsAtCompileTime != Eigen::Dynamic,
"MATRIX_MUST_BE_OF_FIXED_SIZE");
598 return NullaryExpr(ColsAtCompileTime, Eigen::internal::scalar_identity_op<Scalar>());
601 template<
typename Derived>
602 inline const typename SpatialMotionBase<Derived>::IdentityReturnType
603 SpatialMotionBase<Derived>::Identity(Eigen::Index cols) {
604 return NullaryExpr(cols, Eigen::internal::scalar_identity_op<Scalar>());
607 template<
typename Derived>
608 inline const typename SpatialMotionBase<Derived>::BasisReturnType
609 SpatialMotionBase<Derived>::Unit(Eigen::Index i) {
610 static_assert(ColsAtCompileTime == 1,
"MATRIX_MUST_BE_A_VECTOR");
611 return BasisReturnType(SquareMatrixType::Identity(), i);
614 template<
typename Derived>
615 inline const typename SpatialMotionBase<Derived>::BasisReturnType
616 SpatialMotionBase<Derived>::UnitLinX() {
617 return Derived::Unit(0);
620 template<
typename Derived>
621 inline const typename SpatialMotionBase<Derived>::BasisReturnType
622 SpatialMotionBase<Derived>::UnitLinY() {
623 return Derived::Unit(1);
626 template<
typename Derived>
627 inline const typename SpatialMotionBase<Derived>::BasisReturnType
628 SpatialMotionBase<Derived>::UnitLinZ() {
629 return Derived::Unit(2);
632 template<
typename Derived>
633 inline const typename SpatialMotionBase<Derived>::BasisReturnType
634 SpatialMotionBase<Derived>::UnitAngX() {
635 return Derived::Unit(3);
638 template<
typename Derived>
639 inline const typename SpatialMotionBase<Derived>::BasisReturnType
640 SpatialMotionBase<Derived>::UnitAngY() {
641 return Derived::Unit(4);
644 template<
typename Derived>
645 inline const typename SpatialMotionBase<Derived>::BasisReturnType
646 SpatialMotionBase<Derived>::UnitAngZ() {
647 return Derived::Unit(5);
650 template<
typename Derived>
651 inline Derived& SpatialMotionBase<Derived>::setIdentity() {
652 return Eigen::internal::setIdentity_impl<Derived>::run(derived());
655 template<
typename Derived>
656 inline Derived& SpatialMotionBase<Derived>::setIdentity(Eigen::Index cols) {
657 derived().resize(Eigen::NoChange, cols);
658 return setIdentity();
661 template<
typename Derived>
662 inline Derived& SpatialMotionBase<Derived>::setUnit(Eigen::Index i) {
663 static_assert(ColsAtCompileTime == 1,
"MATRIX_MUST_BE_A_VECTOR");
664 eigen_assert(i < size());
666 derived().coeffRef(i) = Scalar(1);
671 template<
typename Derived>
672 template<
typename OtherDerived>
673 inline typename SpatialMotionBase<Derived>::template SpatialOpTraits<OtherDerived>::ScalarT
674 SpatialMotionBase<Derived>::dot(
const SpatialMotionBase<OtherDerived>&)
const {
675 static_assert(std::ptrdiff_t(
sizeof(
typename OtherDerived::Scalar)) == -1,
676 "YOU_CANNOT_DOT_TWO_SPATIAL_MOTION_VECTORS");
680 template<
typename Derived>
681 template<
typename OtherDerived>
682 inline typename SpatialMotionBase<Derived>::template SpatialOpTraits<OtherDerived>::ScalarT
683 SpatialMotionBase<Derived>::dot(
const SpatialForceBase<OtherDerived>& other)
const {
684 static_assert(ColsAtCompileTime == 1,
"MATRIX_MUST_BE_A_VECTOR");
685 static_assert(OtherDerived::ColsAtCompileTime == 1,
"MATRIX_MUST_BE_A_VECTOR");
686 typedef Eigen::internal::scalar_conj_product_op<Scalar, typename OtherDerived::Scalar> conj_prod;
687 return Eigen::CwiseBinaryOp<conj_prod, const Derived, const OtherDerived>(
688 derived(), other.derived(), conj_prod()).sum();
692 template<
typename Derived>
693 template<
typename OtherDerived>
694 inline typename SpatialMotionBase<Derived>::template SpatialOpTraits<OtherDerived>::MotionReturnType
695 SpatialMotionBase<Derived>::cross(
const SpatialMotionBase<OtherDerived>& other)
const {
696 static_assert(ColsAtCompileTime == 1,
"MATRIX_MUST_BE_A_VECTOR");
697 static_assert(OtherDerived::ColsAtCompileTime == 1,
"MATRIX_MUST_BE_A_VECTOR");
698 typename Eigen::internal::nested_eval<Derived,4>::type lhs(derived());
699 typename Eigen::internal::nested_eval<OtherDerived,4>::type rhs(other.derived());
700 return typename SpatialOpTraits<OtherDerived>::MotionReturnType(
701 lhs.coeff(1) * rhs.coeff(5) - lhs.coeff(2) * rhs.coeff(4) + lhs.coeff(4) * rhs.coeff(2) - lhs.coeff(5) * rhs.coeff(1),
702 lhs.coeff(2) * rhs.coeff(3) - lhs.coeff(0) * rhs.coeff(5) + lhs.coeff(5) * rhs.coeff(0) - lhs.coeff(3) * rhs.coeff(2),
703 lhs.coeff(0) * rhs.coeff(4) - lhs.coeff(1) * rhs.coeff(3) + lhs.coeff(3) * rhs.coeff(1) - lhs.coeff(4) * rhs.coeff(0),
704 lhs.coeff(4) * rhs.coeff(5) - lhs.coeff(5) * rhs.coeff(4),
705 lhs.coeff(5) * rhs.coeff(3) - lhs.coeff(3) * rhs.coeff(5),
706 lhs.coeff(3) * rhs.coeff(4) - lhs.coeff(4) * rhs.coeff(3)
710 template<
typename Derived>
711 template<
typename OtherDerived>
712 inline typename SpatialMotionBase<Derived>::template SpatialOpTraits<OtherDerived>::ForceReturnType
713 SpatialMotionBase<Derived>::cross(
const SpatialForceBase<OtherDerived>& other)
const {
714 static_assert(ColsAtCompileTime == 1,
"MATRIX_MUST_BE_A_VECTOR");
715 static_assert(OtherDerived::ColsAtCompileTime == 1,
"MATRIX_MUST_BE_A_VECTOR");
716 typename Eigen::internal::nested_eval<Derived,4>::type lhs(derived());
717 typename Eigen::internal::nested_eval<OtherDerived,4>::type rhs(other.derived());
718 return typename SpatialOpTraits<OtherDerived>::ForceReturnType(
719 lhs.coeff(4) * rhs.coeff(2) - lhs.coeff(5) * rhs.coeff(1),
720 lhs.coeff(5) * rhs.coeff(0) - lhs.coeff(3) * rhs.coeff(2),
721 lhs.coeff(3) * rhs.coeff(1) - lhs.coeff(4) * rhs.coeff(0),
722 lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1) + lhs.coeff(4) * rhs.coeff(5) - lhs.coeff(5) * rhs.coeff(4),
723 lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2) + lhs.coeff(5) * rhs.coeff(3) - lhs.coeff(3) * rhs.coeff(5),
724 lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0) + lhs.coeff(3) * rhs.coeff(4) - lhs.coeff(4) * rhs.coeff(3)
728 template<
typename Derived>
729 template<
typename OtherDerived>
730 inline bool SpatialMotionBase<Derived>::operator==(
const SpatialMotionBase<OtherDerived>& other)
const {
731 return cwiseEqual(other).all();
734 template<
typename Derived>
735 template<
typename OtherDerived>
736 inline bool SpatialMotionBase<Derived>::operator!=(
const SpatialMotionBase<OtherDerived>& other)
const {
737 return cwiseNotEqual(other).any();
740 template<
typename Derived>
741 inline Eigen::MatrixWrapper<Derived> SpatialMotionBase<Derived>::matrix() {
742 return Eigen::MatrixWrapper<Derived>(derived());
745 template<
typename Derived>
746 inline const Eigen::MatrixWrapper<const Derived> SpatialMotionBase<Derived>::matrix()
const {
747 return Eigen::MatrixWrapper<const Derived>(derived());
750 template<
typename Derived>
751 inline Eigen::ArrayWrapper<Derived> SpatialMotionBase<Derived>::array() {
752 return Eigen::ArrayWrapper<Derived>(derived());
755 template<
typename Derived>
756 inline const Eigen::ArrayWrapper<const Derived> SpatialMotionBase<Derived>::array()
const {
757 return Eigen::ArrayWrapper<const Derived>(derived());
760 template<
typename Derived>
761 inline Eigen::Transpose<Eigen::MatrixWrapper<Derived>>
762 SpatialMotionBase<Derived>::transpose() {
763 return Eigen::MatrixWrapper<Derived>(derived()).transpose();
766 template<
typename Derived>
767 inline const Eigen::Transpose<Eigen::MatrixWrapper<const Derived>>
768 SpatialMotionBase<Derived>::transpose()
const {
769 return Eigen::MatrixWrapper<const Derived>(derived()).transpose();
772 template<
typename Derived>
773 inline typename SpatialMotionBase<Derived>::CartesianBlockType
774 SpatialMotionBase<Derived>::linear() {
775 return this->matrix().template topRows<3>();
778 template<
typename Derived>
779 inline typename SpatialMotionBase<Derived>::ConstCartesianBlockType
780 SpatialMotionBase<Derived>::linear()
const {
781 return this->matrix().template topRows<3>();
784 template<
typename Derived>
785 inline typename SpatialMotionBase<Derived>::CartesianBlockType
786 SpatialMotionBase<Derived>::angular() {
787 return this->matrix().template bottomRows<3>();
790 template<
typename Derived>
791 inline typename SpatialMotionBase<Derived>::ConstCartesianBlockType
792 SpatialMotionBase<Derived>::angular()
const {
793 return this->matrix().template bottomRows<3>();
Definition: spatial_force_base.h:18
Definition: spatial_force.h:18
Definition: spatial_motion_base.h:18
Definition: spatial_motion.h:18
Definition: discrete_dynamics.cc:21
Definition: spatial_motion_base.h:113
Definition: spatial_motion_base.h:94
Definition: spatial_motion_base.h:133
Definition: spatial_motion_base.h:80