6 #ifndef LIBBIOMIMETICS_SPATIALINERTIA_H 7 #define LIBBIOMIMETICS_SPATIALINERTIA_H 14 #include <type_traits> 16 #include <eigen3/Eigen/Dense> 27 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
34 _inertia.template topLeftCorner<3, 3>() =
35 inertia + mass * cSkew * cSkew.transpose();
36 _inertia.template topRightCorner<3, 3>() = mass * cSkew;
37 _inertia.template bottomLeftCorner<3, 3>() = mass * cSkew.transpose();
55 _inertia(0, 0) = a(4);
56 _inertia(0, 1) = a(9);
57 _inertia(0, 2) = a(8);
58 _inertia(1, 0) = a(9);
59 _inertia(1, 1) = a(5);
60 _inertia(1, 2) = a(7);
61 _inertia(2, 0) = a(8);
62 _inertia(2, 1) = a(7);
63 _inertia(2, 2) = a(6);
65 _inertia.template topRightCorner<3, 3>() = cSkew;
66 _inertia.template bottomLeftCorner<3, 3>() = cSkew.transpose();
80 Vec3<T> h = P.template topRightCorner<3, 1>();
81 Mat3<T> E = P.template topLeftCorner<3, 3>();
83 I.template topLeftCorner<3, 3>() = Ibar;
96 a << _inertia(5, 5), h(0), h(1), h(2), _inertia(0, 0), _inertia(1, 1),
97 _inertia(2, 2), _inertia(2, 1), _inertia(2, 0), _inertia(1, 0);
120 Mat3<T> mcSkew = _inertia.template topRightCorner<3, 3>();
130 Mat3<T> mcSkew = _inertia.template topRightCorner<3, 3>();
131 Mat3<T> I_rot = _inertia.template topLeftCorner<3, 3>() -
132 mcSkew * mcSkew.transpose() / m;
144 Mat3<T> Ibar = _inertia.template topLeftCorner<3, 3>();
145 T m = _inertia(5, 5);
147 P.template topLeftCorner<3, 3>() =
149 P.template topRightCorner<3, 1>() = h;
150 P.template bottomLeftCorner<1, 3>() = h.transpose();
159 Mat4<T> P = getPseudoInertia();
175 #endif // LIBBIOMIMETICS_SPATIALINERTIA_H
typename Eigen::Matrix< T, 6, 6 > Mat6
typename Eigen::Matrix< T, 3, 3 > Mat3
const Mat6< T > & getMatrix() const
SpatialInertia(const Mat4< T > &P)
typename Eigen::Matrix< T, 4, 4 > Mat4
typename Eigen::Matrix< T, 3, 1 > Vec3
Mat3< T > getInertiaTensor()
SpatialInertia flipAlongAxis(CoordinateAxis axis)
MassProperties< T > asMassPropertyVector()
void addMatrix(const Mat6< T > &mat)
Mat4< T > getPseudoInertia()
EIGEN_MAKE_ALIGNED_OPERATOR_NEW SpatialInertia(T mass, const Vec3< T > &com, const Mat3< T > &inertia)
SpatialInertia(const MassProperties< T > &a)
Mat3< typename T::Scalar > vectorToSkewMat(const Eigen::MatrixBase< T > &v)
Vec3< typename T::Scalar > matToSkewVec(const Eigen::MatrixBase< T > &m)
void setMatrix(const Mat6< T > &mat)
typename Eigen::Matrix< T, 10, 1 > MassProperties
SpatialInertia(const Mat6< T > &inertia)
Utility functions for manipulating spatial quantities.