12 using namespace Eigen;
25 CPPUNIT_ASSERT(Map<Matrix3d>(I0.
data).isZero());
27 CPPUNIT_ASSERT(Map<Matrix3d>(I1.data).isZero());
28 CPPUNIT_ASSERT(Map<Matrix3d>(I0.
data).isApprox(Map<Matrix3d>(I1.data)));
33 CPPUNIT_ASSERT(Map<Matrix3d>(I3.
data).isApprox(Map<Matrix3d>(I2.data)));
35 CPPUNIT_ASSERT(!Map<Matrix3d>(I3.
data).isApprox(Map<Matrix3d>(I2.data)));
38 Map<Matrix3d>(I0.
data).setRandom();
40 CPPUNIT_ASSERT(!Map<Matrix3d>(I1.data).isZero());
42 CPPUNIT_ASSERT(Map<Matrix3d>(I1.data).isZero());
45 CPPUNIT_ASSERT(Map<Matrix3d>(I2.data).isApprox(Map<Matrix3d>(I2.data).transpose()));
52 CPPUNIT_ASSERT(Map<Vector3d>(momentum.
data).isApprox(Map<Matrix3d>(I2.data)*Map<Vector3d>(omega.data)));
63 Matrix3d Ic_eig = Matrix3d::Random();
65 Map<Matrix3d>(Ic.
data)=Ic_eig+Ic_eig.transpose();
68 CPPUNIT_ASSERT_EQUAL(I2.
getMass(),mass);
70 CPPUNIT_ASSERT_EQUAL(I2.
getCOG(),c);
80 CPPUNIT_ASSERT_DOUBLES_EQUAL(I4.getMass(),0.0,
epsilon);
82 CPPUNIT_ASSERT(Map<Matrix3d>(I4.getRotationalInertia().data).isZero());
91 CPPUNIT_ASSERT_DOUBLES_EQUAL(I2.getMass(),I4.getMass(),
epsilon);
92 CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
93 CPPUNIT_ASSERT(Map<Matrix3d>(I2.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
97 CPPUNIT_ASSERT_DOUBLES_EQUAL(I3.getMass(),I4.getMass(),
epsilon);
98 CPPUNIT_ASSERT_EQUAL(I3.getCOG(),I4.getCOG());
99 CPPUNIT_ASSERT(Map<Matrix3d>(I3.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
105 I4 = I3.RefPoint(-p);
106 CPPUNIT_ASSERT_DOUBLES_EQUAL(I2.getMass(),I4.getMass(),
epsilon);
107 CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
108 CPPUNIT_ASSERT(Map<Matrix3d>(I2.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
111 CPPUNIT_ASSERT_DOUBLES_EQUAL(I3.getMass(),I4.getMass(),
epsilon);
112 CPPUNIT_ASSERT_EQUAL(I3.getCOG(),I4.getCOG());
113 CPPUNIT_ASSERT(Map<Matrix3d>(I3.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
122 CPPUNIT_ASSERT_EQUAL(T*f,(T*I2)*(T*a));
127 CPPUNIT_ASSERT_DOUBLES_EQUAL(I2.getMass(),I4.getMass(),
epsilon);
128 CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
129 CPPUNIT_ASSERT(Map<Matrix3d>(I2.getRotationalInertia().data).isApprox(Map<Matrix3d>(I4.getRotationalInertia().data)));
138 Matrix3d::Map(Ic.
data).triangularView<Lower>()= Matrix3d::Random().triangularView<Lower>();
143 CPPUNIT_ASSERT_EQUAL(I2.
M,I1.
M);
144 CPPUNIT_ASSERT_EQUAL(I2.
H,I1.
H);
145 CPPUNIT_ASSERT_EQUAL(I2.
I,I1.
I);
147 CPPUNIT_ASSERT_EQUAL(I2.
M,I1.
M);
148 CPPUNIT_ASSERT_EQUAL(I2.
H,I1.
H);
149 CPPUNIT_ASSERT_EQUAL(I2.
I,I1.
I);
151 CPPUNIT_ASSERT_EQUAL(I2.
M,(Matrix3d::Identity()*mass).eval());
152 CPPUNIT_ASSERT(!I2.
I.isZero());
157 CPPUNIT_ASSERT(I2.
M.isApprox(I3.M));
158 CPPUNIT_ASSERT(I2.
H.isApprox(I3.H));
159 CPPUNIT_ASSERT(I2.
I.isApprox(I3.I));
162 CPPUNIT_ASSERT(I4.M.isApprox(Matrix3d::Zero().eval()));
163 CPPUNIT_ASSERT(I4.H.isApprox(Matrix3d::Zero().eval()));
164 CPPUNIT_ASSERT(I4.I.isApprox(Matrix3d::Zero().eval()));
172 Map<Matrix3d> E(R.
data);
173 Matrix3d tmp = E.transpose()*I2.M*E;
174 CPPUNIT_ASSERT(I3.M.isApprox(tmp));
175 tmp = E.transpose()*I2.H*E;
176 CPPUNIT_ASSERT(I3.H.isApprox(tmp));
177 tmp = E.transpose()*I2.I*E;
178 CPPUNIT_ASSERT(I3.I.isApprox(tmp));
181 CPPUNIT_ASSERT(I2.M.isApprox(I4.M));
182 CPPUNIT_ASSERT(I2.H.isApprox(I4.H));
183 CPPUNIT_ASSERT(I2.I.isApprox(I4.I));
187 CPPUNIT_ASSERT(I3.M.isApprox(I4.M));
188 CPPUNIT_ASSERT(I3.H.isApprox(I4.H));
189 CPPUNIT_ASSERT(I3.I.isApprox(I4.I));
195 I4 = I3.RefPoint(-p);
196 CPPUNIT_ASSERT(I2.M.isApprox(I4.M));
197 CPPUNIT_ASSERT(I2.H.isApprox(I4.H));
198 CPPUNIT_ASSERT(I2.I.isApprox(I4.I));
201 CPPUNIT_ASSERT(I3.M.isApprox(I4.M));
202 CPPUNIT_ASSERT(I3.H.isApprox(I4.H));
203 CPPUNIT_ASSERT(I3.I.isApprox(I4.I));
213 CPPUNIT_ASSERT_EQUAL(T*f,(T*I2)*(T*a));
218 CPPUNIT_ASSERT(I2.M.isApprox(I4.M));
219 CPPUNIT_ASSERT(I2.H.isApprox(I4.H));
220 CPPUNIT_ASSERT(I2.I.isApprox(I4.I));
represents rotations in 3 dimensional space.
void TestArticulatedBodyInertia()
Rotation Inverse() const
Gives back the inverse rotation matrix of *this.
6D Inertia of a rigid body
void TestRigidBodyInertia()
doubleAcc dot(const VectorAcc &lhs, const VectorAcc &rhs)
CPPUNIT_TEST_SUITE_REGISTRATION(InertiaTest)
represents both translational and rotational velocities.
6D Inertia of a articulated body
A concrete implementation of a 3 dimensional vector class.
double epsilon
default precision while comparing with Equal(..,..) functions. Initialized at 0.0000001.
static RotationalInertia Zero()
represents a frame transformation in 3D space (rotation + translation)
represents both translational and rotational acceleration.
RotationalInertia getRotationalInertia() const
IMETHOD void random(Vector &a)
addDelta operator for displacement rotational velocity.
void TestRotationalInertia()