Fix for is_orthogonal check which in fact was checking for orthonormal matrix.

Separated it into two functions so now it'll be clear if check happens for
orthonormal or just orthogonal.
This commit is contained in:
2012-04-01 00:14:41 +00:00
parent 8f949dd58d
commit 26b0255049
3 changed files with 54 additions and 5 deletions

View File

@@ -2230,6 +2230,27 @@ static PyObject *Matrix_is_orthogonal_get(MatrixObject *self, void *UNUSED(closu
}
}
PyDoc_STRVAR(Matrix_is_orthonormal_doc,
"True if this matrix is orthonormal, 3x3 and 4x4 only, (read-only).\n\n:type: bool"
);
static PyObject *Matrix_is_orthonormal_get(MatrixObject *self, void *UNUSED(closure))
{
if (BaseMath_ReadCallback(self) == -1)
return NULL;
/*must be 3-4 cols, 3-4 rows, square matrix*/
if (self->num_row == 4 && self->num_col == 4)
return PyBool_FromLong(is_orthonormal_m4((float (*)[4])self->matrix));
else if (self->num_row == 3 && self->num_col == 3)
return PyBool_FromLong(is_orthonormal_m3((float (*)[3])self->matrix));
else {
PyErr_SetString(PyExc_AttributeError,
"Matrix.is_orthonormal: "
"inappropriate matrix size - expects 3x3 or 4x4 matrix");
return NULL;
}
}
/*****************************************************************************/
/* Python attributes get/set structure: */
/*****************************************************************************/
@@ -2240,6 +2261,7 @@ static PyGetSetDef Matrix_getseters[] = {
{(char *)"col", (getter)Matrix_col_get, (setter)NULL, Matrix_col_doc, NULL},
{(char *)"is_negative", (getter)Matrix_is_negative_get, (setter)NULL, Matrix_is_negative_doc, NULL},
{(char *)"is_orthogonal", (getter)Matrix_is_orthogonal_get, (setter)NULL, Matrix_is_orthogonal_doc, NULL},
{(char *)"is_orthonormal", (getter)Matrix_is_orthonormal_get, (setter)NULL, Matrix_is_orthonormal_doc, NULL},
{(char *)"is_wrapped", (getter)BaseMathObject_is_wrapped_get, (setter)NULL, BaseMathObject_is_wrapped_doc, NULL},
{(char *)"owner", (getter)BaseMathObject_owner_get, (setter)NULL, BaseMathObject_owner_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */