[go: up one dir, main page]

Menu

[f35cf5]: / body / test_Rigid_Body.cc  Maximize  Restore  History

Download this file

38 lines (32 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE Rigid_Body
#include <boost/test/unit_test.hpp>
#include <boost/test/tools/floating_point_comparison.hpp>
#include "Rigid_Body.h"
#include "../geometry/Constants.h"
using namespace Vamos_Body;
using namespace Vamos_Geometry;
Three_Matrix identity;
struct Cube_Fixture
{
Cube_Fixture ()
: body (Three_Vector (), Three_Matrix ())
{
body.add_particle (new Particle (1.0, Three_Vector (0.0, 0.0, 0.0)));
body.add_particle (new Particle (1.0, Three_Vector (1.0, 0.0, 0.0)));
body.add_particle (new Particle (1.0, Three_Vector (0.0, 1.0, 0.0)));
body.add_particle (new Particle (1.0, Three_Vector (1.0, 1.0, 0.0)));
body.add_particle (new Particle (1.0, Three_Vector (0.0, 0.0, 1.0)));
body.add_particle (new Particle (1.0, Three_Vector (1.0, 0.0, 1.0)));
body.add_particle (new Particle (1.0, Three_Vector (0.0, 1.0, 1.0)));
body.add_particle (new Particle (1.0, Three_Vector (1.0, 1.0, 1.0)));
body.update_center_of_mass ();
}
Rigid_Body body;
};
BOOST_AUTO_TEST_CASE (cube_properties)
{
Cube_Fixture f;
BOOST_CHECK_EQUAL (f.body.mass (), 8.0);
BOOST_CHECK_EQUAL (f.body.cm_position (), Three_Vector (0.5, 0.5, 0.5));
}