0000856: Wrong inverse of a matrix

This commit is contained in:
wmayer 2012-10-22 16:21:27 +02:00
parent ec3c79ad9c
commit 642a3e5094
3 changed files with 10 additions and 3 deletions

View File

@ -134,9 +134,11 @@ public:
/// transform (move,scale,rotate) around a point /// transform (move,scale,rotate) around a point
void transform (const Vector3f& rclVct, const Matrix4D& rclMtrx); void transform (const Vector3f& rclVct, const Matrix4D& rclMtrx);
void transform (const Vector3d& rclVct, const Matrix4D& rclMtrx); void transform (const Vector3d& rclVct, const Matrix4D& rclMtrx);
/// Matrix is expected to have a 3x3 rotation matrix.
void inverse (void); void inverse (void);
/// if matrix is orthogonal a special way of getting the inverse is used /// Matrix is expected to have a 3x3 rotation matrix.
void inverseOrthogonal(void); void inverseOrthogonal(void);
/// Arbitrary, non-singular matrix
void inverseGauss (void); void inverseGauss (void);
void transpose (void); void transpose (void);
//@} //@}

View File

@ -342,7 +342,7 @@ PyObject* MatrixPy::invert(PyObject * args)
PY_TRY { PY_TRY {
if (getMatrixPtr()->determinant() > DBL_EPSILON) if (getMatrixPtr()->determinant() > DBL_EPSILON)
getMatrixPtr()->inverse(); getMatrixPtr()->inverseGauss();
else { else {
PyErr_SetString(PyExc_Exception, "Cannot invert singular matrix"); PyErr_SetString(PyExc_Exception, "Cannot invert singular matrix");
return 0; return 0;
@ -361,7 +361,7 @@ PyObject* MatrixPy::inverse(PyObject * args)
PY_TRY { PY_TRY {
if (getMatrixPtr()->determinant() > DBL_EPSILON) { if (getMatrixPtr()->determinant() > DBL_EPSILON) {
Base::Matrix4D m = *getMatrixPtr(); Base::Matrix4D m = *getMatrixPtr();
m.inverse(); m.inverseGauss();
return new MatrixPy(m); return new MatrixPy(m);
} }
else { else {

View File

@ -149,6 +149,11 @@ class ParameterTestCase(unittest.TestCase):
self.TestPar.RemString("44") self.TestPar.RemString("44")
self.failUnless(self.TestPar.GetString("44","hallo") == "hallo","Deletion error at String") self.failUnless(self.TestPar.GetString("44","hallo") == "hallo","Deletion error at String")
def testMatrix(self):
m=FreeCAD.Matrix(4,2,1,0,1,1,1,0,0,0,1,0,0,0,0,1)
u=m.multiply(m.inverse())
self.failUnless(u==FreeCAD.Matrix(),"Invalid inverse of matrix")
def testNesting(self): def testNesting(self):
# Parameter testing # Parameter testing
#FreeCAD.Console.PrintLog("Base::ParameterTestCase::testNesting\n") #FreeCAD.Console.PrintLog("Base::ParameterTestCase::testNesting\n")