33 #include<vcg/complex/complex.h>
35 #include<wrap/io_trimesh/import_off.h>
37 #include<vcg/complex/algorithms/inertia.h>
38 #include<vcg/complex/algorithms/create/platonic.h>
43 struct MyUsedTypes :
public vcg::UsedTypes< vcg::Use<MyVertex> ::AsVertexType,
44 vcg::Use<MyEdge> ::AsEdgeType,
45 vcg::Use<MyFace> ::AsFaceType>{};
47 class MyVertex :
public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};
48 class MyFace :
public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::Normal3f, vcg::face::VertexRef, vcg::face::BitFlags > {};
49 class MyEdge :
public vcg::Edge<MyUsedTypes>{};
50 class MyMesh :
public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {};
52 int main(
int argc,
char **argv )
54 MyMesh boxMesh,torusMesh;
58 vcg::tri::Hexahedron(boxMesh);
59 vcg::Matrix44f ScaleM,TransM;
60 ScaleM.SetScale(1.0f, 2.0f, 5.0f);
61 TransM.SetTranslate(2.0f,3.0f,4.0f);
65 vcg::Point3f cc = Ib.CenterOfMass();
66 Ib.InertiaTensorEigen(IT,ITv);
68 printf(
"Box of size 2,4,10, centered in (2,3,4)\n");
69 printf(
"Volume %f \n",Ib.Mass());
70 printf(
"CenterOfMass %f %f %f\n",cc[0],cc[1],cc[2]);
71 printf(
"InertiaTensor Values %6.3f %6.3f %6.3f\n",ITv[0],ITv[1],ITv[2]);
72 printf(
"InertiaTensor Matrix\n");
74 printf(
" %6.3f %6.3f %6.3f\n",IT[0][0],IT[0][1],IT[0][2]);
75 printf(
" %6.3f %6.3f %6.3f\n",IT[1][0],IT[1][1],IT[1][2]);
76 printf(
" %6.3f %6.3f %6.3f\n",IT[2][0],IT[2][1],IT[2][2]);
86 vcg::tri::Torus(torusMesh,2,1,1024,512);
88 cc = It.CenterOfMass();
89 It.InertiaTensorEigen(IT,ITv);
91 printf(
"\nTorus of radius 2,1\n");
92 printf(
"Mass %f \n",It.Mass());
93 printf(
"CenterOfMass %f %f %f\n",cc[0],cc[1],cc[2]);
94 printf(
"InertiaTensor Values %6.3f %6.3f %6.3f\n",ITv[0],ITv[1],ITv[2]);
95 printf(
"InertiaTensor Matrix\n");
97 printf(
" %6.3f %6.3f %6.3f\n",IT[0][0],IT[0][1],IT[0][2]);
98 printf(
" %6.3f %6.3f %6.3f\n",IT[1][0],IT[1][1],IT[1][2]);
99 printf(
" %6.3f %6.3f %6.3f\n",IT[2][0],IT[2][1],IT[2][2]);