From eb2e4a7a736947e01a92dbb16ef0f470cfbe34dd Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 22 Dec 2011 14:15:44 +0000 Subject: [PATCH] + add attribute MatrixOfInertia to solid git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5337 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Part/App/TopoShapeSolidPy.xml | 21 +++++++++++++++++++++ src/Mod/Part/App/TopoShapeSolidPyImp.cpp | 14 ++++++++++++++ 2 files changed, 35 insertions(+) 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;