
Tue, 01/20/2004 - 12:03
Hi,
I want to calculate the inertia matrix of a cube. It is calculated this way :
// Cube creation
gp_Pnt Pnt1(-5,-5,-5);
gp_Pnt Pnt2(5,5,5);
BRepPrimAPI_MakeBox MakeBox(Pnt1, Pnt2);
TopoDS_Shell myBlock = MakeBox.Shell();
// The cube is created
// We get back the barycenter of the cube
gp_Pnt origin;
GProp_GProps Props;
BRepGProp::VolumeProperties(myBlock, Props);
origin = Props.CentreOfMass();
// We have the barycenter
// We get back the Inertia matrix
gp_Mat Mat;
GProp_GProps VProps(origin);
BRepGProp::VolumeProperties(myBlock, VProps);
Mat = VProps.MatrixOfInertia();
The matrix I get back is diagonal. But it never changes even if I apply a rotation on the cube. The matrix is always diagonal. Is it accurate ?
Unlike the cube, the inertia matrix of a cylinder is not always diagonal. It changes if the cylinder rotates.
Have I forget something ? Do I an error somewhere ?
Thank you for your help.
Patrick.
Thu, 01/22/2004 - 15:39
I think you are calculating the Inertia about the center of mass of the cube and this is always the same, even if the cube is rotated. Try the next code:
GProp_GProps Props;
BRepGProp::VolumeProperties(myBlock, Props);
origin = Props.CentreOfMass();
gp_Mat Mat;
Mat = Props.MatrixOfInertia();
Good luck
Tue, 01/27/2004 - 10:58
Thank you very much for your answer. It helps me a lot.
best regards,
Patrick Resch.
Thu, 01/22/2004 - 16:49
Hello
The inertia matrix of a cube never changes when you apply rotations around the center of mass because the terms on the diagonal are equal.
For a cylinder terms are differents on the diagonal and when you compute R(transpose)*I*R the result is a non diagonal matrix.
It is not an error
jerome