diff --git a/src/Mod/Part/App/TopoShapeSolidPy.xml b/src/Mod/Part/App/TopoShapeSolidPy.xml index 53d21f3875..0e3a3705d1 100644 --- a/src/Mod/Part/App/TopoShapeSolidPy.xml +++ b/src/Mod/Part/App/TopoShapeSolidPy.xml @@ -23,6 +23,27 @@ absolute Cartesian coordinate system. + + + Returns the matrix of inertia. It is a symmetrical matrix. +The coefficients of the matrix are the quadratic moments of +inertia. + + | Ixx Ixy Ixz 0 | + | Ixy Iyy Iyz 0 | + | Ixz Iyz Izz 0 | + | 0 0 0 1 | + +The moments of inertia are denoted by Ixx, Iyy, Izz. +The products of inertia are denoted by Ixy, Ixz, Iyz. +The matrix of inertia is returned in the central coordinate +system (G, Gx, Gy, Gz) where G is the centre of mass of the +system and Gx, Gy, Gz the directions parallel to the X(1,0,0) +Y(0,1,0) Z(0,0,1) directions of the absolute cartesian +coordinate system. + + + diff --git a/src/Mod/Part/App/TopoShapeSolidPyImp.cpp b/src/Mod/Part/App/TopoShapeSolidPyImp.cpp index 2ab75c2d76..291dba419b 100644 --- a/src/Mod/Part/App/TopoShapeSolidPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeSolidPyImp.cpp @@ -91,6 +91,20 @@ int TopoShapeSolidPy::PyInit(PyObject* args, PyObject* /*kwd*/) return 0; } +Py::Object TopoShapeSolidPy::getMatrixOfInertia(void) const +{ + GProp_GProps props; + BRepGProp::VolumeProperties(getTopoShapePtr()->_Shape, props); + gp_Mat m = props.MatrixOfInertia(); + Base::Matrix4D mat; + for (int i=0; i<3; i++) { + for (int j=0; j<3; j++) { + mat[i][j] = m(i+1,j+1); + } + } + return Py::Matrix(mat); +} + Py::Object TopoShapeSolidPy::getCenterOfMass(void) const { GProp_GProps props;