0000623: Matrix and Vector API extension

This commit is contained in:
wmayer
2012-03-12 11:13:58 +01:00
parent 02a962207b
commit 8a57a948d3
2 changed files with 14 additions and 10 deletions

View File

@@ -24,6 +24,7 @@
#include "PreCompiled.h"
#include <climits>
#include <cmath>
#include "Base/Matrix.h"
// inclusion of the generated files (generated out of MatrixPy.xml)
@@ -415,32 +416,34 @@ PyObject* MatrixPy::submatrix(PyObject * args)
PyObject* MatrixPy::isOrthogonal(PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
double eps=1.0e-06;
if (!PyArg_ParseTuple(args, "|d",&eps))
return 0;
const Base::Matrix4D& mat = *getMatrixPtr();
Base::Matrix4D trp = mat;
trp.transpose();
trp = trp * mat;
bool ok = true;
double mult = trp[0][0];
for (int i=0; (i<4) && (mult!=0.0); i++) {
for (int j=0; (j<4) && (mult!=0.0); j++) {
for (int i=0; i<4 && ok; i++) {
for (int j=0; j<4 && ok; j++) {
if (i != j) {
if (trp[i][j] != 0.0) {
mult = 0.0;
if (fabs(trp[i][j]) > eps) {
ok = false;
break;
}
}
else { // the diagonal
if (trp[i][j] != mult) {
mult = 0.0;
else { // the main diagonal
if (fabs(trp[i][j]-mult) > eps) {
ok = false;
break;
}
}
}
}
return Py::new_reference_to(Py::Float(mult));
return Py::new_reference_to(Py::Float(ok ? mult : 0.0));
}
PyObject* MatrixPy::transposed(PyObject * args)