did you test your code when your shape is a cylinder? Because, when a shape is a cylinder, the first axis of inertia is not the axis of rotation !!!
theShape is a solid, a cylinder GProp_GProps aGProperties; BRepGProp::SurfaceProperties(theShape, aGProperties); GProp_PrincipalProps aPrincipalProps = aGProperties.PrincipalProperties(); gp_Vec aVec; aVec = aPrincipalProps.FirstAxisOfInertia();
I ask u the same question when u use a face. In fact, when u use a cylindrical face, the first axis of inertia is not the axis of rotation !!
theShape is a cylindrical face GProp_GProps aGProperties; BRepGProp::SurfaceProperties(theShape, aGProperties); GProp_PrincipalProps aPrincipalProps = aGProperties.PrincipalProperties(); gp_Vec aVec; aVec = aPrincipalProps.FirstAxisOfInertia();
Perhaps, I make a mistake when i use this method. Can u help me ?
Olivier Coma (not verified) Fri, 12/07/2001 - 16:48
Hi,
I agreed that when the shape is a cylinder, the first axis of inertia is not necessarily the axis of rotation (Z) but it is just normal.
If you want to get a trihedron for a solid, you have to use BRepGProp::VolumeProperties. If you want to find the axis of rotation of a cylindrical face, using BRepGProp::SurfaceProperties is not a good solution. I use the following code :
//F is a TopoDS_Face BRepAdaptor_Surface AF(F); if (AF.GetType()!=GeomAbs_Cylinder) return; gp_Cylinder C=AF.Surface().Cylinder(); C.Transform(AF.Trsf()); gp_Dir Z=C.Axis().Direction();
Olivier Coma (not verified) Fri, 12/07/2001 - 21:49
Hi,
I am sorry but what you have just wroten is false. Principal inertia axes are the eigen vectors of the inertia matrix. First, second and third principal axis are respectively those relative to the first, second and third eigen value of the inertia matrix (that is symmetric and orthogonal). More, eigen values (that are the principal moments of inertia) are ordered by decreasing values.
For a cylinder, two eigen values have the same value, since a cylinder has a rotational symetry, and the third eigen value can be either inferior or superior to the two others, depending on the ratio l/d of the cylinder. Tipically, if a cylinder is a disc (l/d <<), the axis of rotation is the first principal axis of inertia. But if the cylinder is long (l/d >>), the axis of rotation is the third one.
Finally, if the cylinder has a small feature on its shape, so that it is not still symmetric, all these considerations become false. None of the principal axes is the axis of the cylinder.
Thu, 11/29/2001 - 00:56
Hi,
If you want to retrieve an axis from the principal properties of inertia of a shape, you can use the following code :
//S is a solid gp_Ax2 Position; GProp_GProps System; BRepGProp::VolumeProperties(S, System); GProp_PrincipalProps Pp=System.PrincipalProperties(); Position.SetLocation(System.CentreOfMass()); Position.SetDirection(Pp.FirstAxisOfInertia()); Position.SetXDirection(Pp.SecondAxisOfInertia());
I hope this code will help you.
Thu, 12/06/2001 - 13:19
hi,
did you test your code when your shape is a cylinder? Because, when a shape is a cylinder, the first axis of inertia is not the axis of rotation !!!
theShape is a solid, a cylinder GProp_GProps aGProperties; BRepGProp::SurfaceProperties(theShape, aGProperties); GProp_PrincipalProps aPrincipalProps = aGProperties.PrincipalProperties(); gp_Vec aVec; aVec = aPrincipalProps.FirstAxisOfInertia();
I ask u the same question when u use a face. In fact, when u use a cylindrical face, the first axis of inertia is not the axis of rotation !!
theShape is a cylindrical face GProp_GProps aGProperties; BRepGProp::SurfaceProperties(theShape, aGProperties); GProp_PrincipalProps aPrincipalProps = aGProperties.PrincipalProperties(); gp_Vec aVec; aVec = aPrincipalProps.FirstAxisOfInertia();
Perhaps, I make a mistake when i use this method. Can u help me ?
Fri, 12/07/2001 - 16:48
Hi,
I agreed that when the shape is a cylinder, the first axis of inertia is not necessarily the axis of rotation (Z) but it is just normal.
If you want to get a trihedron for a solid, you have to use BRepGProp::VolumeProperties. If you want to find the axis of rotation of a cylindrical face, using BRepGProp::SurfaceProperties is not a good solution. I use the following code :
//F is a TopoDS_Face BRepAdaptor_Surface AF(F); if (AF.GetType()!=GeomAbs_Cylinder) return; gp_Cylinder C=AF.Surface().Cylinder(); C.Transform(AF.Trsf()); gp_Dir Z=C.Axis().Direction();
Fri, 12/07/2001 - 18:18
hi,
in fact, the axis of rotation of a cylinder is the third axis of inertia.
thanks for u help.
ps: i knew your method to find the axis of rotation
Fri, 12/07/2001 - 21:49
Hi,
I am sorry but what you have just wroten is false. Principal inertia axes are the eigen vectors of the inertia matrix. First, second and third principal axis are respectively those relative to the first, second and third eigen value of the inertia matrix (that is symmetric and orthogonal). More, eigen values (that are the principal moments of inertia) are ordered by decreasing values.
For a cylinder, two eigen values have the same value, since a cylinder has a rotational symetry, and the third eigen value can be either inferior or superior to the two others, depending on the ratio l/d of the cylinder. Tipically, if a cylinder is a disc (l/d <<), the axis of rotation is the first principal axis of inertia. But if the cylinder is long (l/d >>), the axis of rotation is the third one.
Finally, if the cylinder has a small feature on its shape, so that it is not still symmetric, all these considerations become false. None of the principal axes is the axis of the cylinder.