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)-Map<Matrix3d>(I1.data)).isZero());
33 CPPUNIT_ASSERT((Map<Matrix3d>(I3.
data)-Map<Matrix3d>(I2.data)).isZero());
35 CPPUNIT_ASSERT(!(Map<Matrix3d>(I3.
data)-Map<Matrix3d>(I2.data)).isZero());
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)-Map<Matrix3d>(I2.data).transpose()).isZero());
52 CPPUNIT_ASSERT((Map<Vector3d>(momentum.
data)-(Map<Matrix3d>(I2.data)*Map<Vector3d>(omega.data))).isZero());
62 Matrix3d Ic_eig = Matrix3d::Random();
64 Map<Matrix3d>(Ic.
data)=Ic_eig+Ic_eig.transpose();
67 CPPUNIT_ASSERT_EQUAL(I2.
getMass(),mass);
69 CPPUNIT_ASSERT_EQUAL(I2.
getCOG(),c);
70 CPPUNIT_ASSERT((Map<Matrix3d>(I2.
getRotationalInertia().
data)-(Map<Matrix3d>(Ic.
data)-mass*(Map<Vector3d>(c.
data)*Map<Vector3d>(c.
data).transpose()-(Map<Vector3d>(c.
data).
dot(Map<Vector3d>(c.
data))*Matrix3d::Identity())))).isZero());
74 CPPUNIT_ASSERT_EQUAL(I2.
getMass(),I3.getMass());
75 CPPUNIT_ASSERT_EQUAL(I2.
getCOG(),I3.getCOG());
76 CPPUNIT_ASSERT((Map<Matrix3d>(I2.
getRotationalInertia().
data)-Map<Matrix3d>(I3.getRotationalInertia().data)).isZero());
79 CPPUNIT_ASSERT_DOUBLES_EQUAL(I4.getMass(),0.0,
epsilon);
81 CPPUNIT_ASSERT(Map<Matrix3d>(I4.getRotationalInertia().data).isZero());
90 CPPUNIT_ASSERT_DOUBLES_EQUAL(I2.getMass(),I4.getMass(),
epsilon);
91 CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
92 CPPUNIT_ASSERT((Map<Matrix3d>(I2.getRotationalInertia().data)-Map<Matrix3d>(I4.getRotationalInertia().data)).isZero());
96 CPPUNIT_ASSERT_DOUBLES_EQUAL(I3.getMass(),I4.getMass(),
epsilon);
97 CPPUNIT_ASSERT_EQUAL(I3.getCOG(),I4.getCOG());
98 CPPUNIT_ASSERT((Map<Matrix3d>(I3.getRotationalInertia().data)-Map<Matrix3d>(I4.getRotationalInertia().data)).isZero());
104 I4 = I3.RefPoint(-p);
105 CPPUNIT_ASSERT_DOUBLES_EQUAL(I2.getMass(),I4.getMass(),
epsilon);
106 CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
107 CPPUNIT_ASSERT((Map<Matrix3d>(I2.getRotationalInertia().data)-Map<Matrix3d>(I4.getRotationalInertia().data)).isZero());
110 CPPUNIT_ASSERT_DOUBLES_EQUAL(I3.getMass(),I4.getMass(),
epsilon);
111 CPPUNIT_ASSERT_EQUAL(I3.getCOG(),I4.getCOG());
112 CPPUNIT_ASSERT((Map<Matrix3d>(I3.getRotationalInertia().data)-Map<Matrix3d>(I4.getRotationalInertia().data)).isZero());
121 CPPUNIT_ASSERT_EQUAL(T*f,(T*I2)*(T*a));
126 CPPUNIT_ASSERT_DOUBLES_EQUAL(I2.getMass(),I4.getMass(),
epsilon);
127 CPPUNIT_ASSERT_EQUAL(I2.getCOG(),I4.getCOG());
128 CPPUNIT_ASSERT((Map<Matrix3d>(I2.getRotationalInertia().data)-Map<Matrix3d>(I4.getRotationalInertia().data)).isZero());
137 Matrix3d::Map(Ic.
data).triangularView<Lower>()= Matrix3d::Random().triangularView<Lower>();
142 CPPUNIT_ASSERT_EQUAL(I2.
M,I1.
M);
143 CPPUNIT_ASSERT_EQUAL(I2.
H,I1.
H);
144 CPPUNIT_ASSERT_EQUAL(I2.
I,I1.
I);
146 CPPUNIT_ASSERT_EQUAL(I2.
M,I1.
M);
147 CPPUNIT_ASSERT_EQUAL(I2.
H,I1.
H);
148 CPPUNIT_ASSERT_EQUAL(I2.
I,I1.
I);
150 CPPUNIT_ASSERT_EQUAL(I2.
M,(Matrix3d::Identity()*mass).eval());
151 CPPUNIT_ASSERT(!I2.
I.isZero());
156 CPPUNIT_ASSERT((I2.
M-I3.M).isZero());
157 CPPUNIT_ASSERT((I2.
H-I3.H).isZero());
158 CPPUNIT_ASSERT((I2.
I-I3.I).isZero());
161 CPPUNIT_ASSERT(I4.M.isZero());
162 CPPUNIT_ASSERT(I4.H.isZero());
163 CPPUNIT_ASSERT(I4.I.isZero());
171 Map<Matrix3d> E(R.data);
172 Matrix3d tmp = E.transpose()*I2.M*E;
173 CPPUNIT_ASSERT((I3.M-tmp).isZero());
174 tmp = E.transpose()*I2.H*E;
175 CPPUNIT_ASSERT((I3.H-tmp).isZero());
176 tmp = E.transpose()*I2.I*E;
177 CPPUNIT_ASSERT((I3.I-tmp).isZero());
180 CPPUNIT_ASSERT((I2.M-I4.M).isZero());
181 CPPUNIT_ASSERT((I2.H-I4.H).isZero());
182 CPPUNIT_ASSERT((I2.I-I4.I).isZero());
186 CPPUNIT_ASSERT((I3.M-I4.M).isZero());
187 CPPUNIT_ASSERT((I3.H-I4.H).isZero());
188 CPPUNIT_ASSERT((I3.I-I4.I).isZero());
194 I4 = I3.RefPoint(-p);
195 CPPUNIT_ASSERT((I2.M-I4.M).isZero());
196 CPPUNIT_ASSERT((I2.H-I4.H).isZero());
197 CPPUNIT_ASSERT((I2.I-I4.I).isZero());
200 CPPUNIT_ASSERT((I3.M-I4.M).isZero());
201 CPPUNIT_ASSERT((I3.H-I4.H).isZero());
202 CPPUNIT_ASSERT((I3.I-I4.I).isZero());
212 CPPUNIT_ASSERT_EQUAL(T*f,(T*I2)*(T*a));
217 CPPUNIT_ASSERT((I2.M-I4.M).isZero());
218 CPPUNIT_ASSERT((I2.H-I4.H).isZero());
219 CPPUNIT_ASSERT((I2.I-I4.I).isZero());
represents rotations in 3 dimensional space.
void TestArticulatedBodyInertia()
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()