From e63eaf90755fb880441f3472d04c8d2387795fbc Mon Sep 17 00:00:00 2001 From: Sebastian Hoogen Date: Tue, 15 May 2012 18:01:15 +0200 Subject: [PATCH] add isNull() method to Rotation --- src/Base/RotationPy.xml | 8 ++++++++ src/Base/RotationPyImp.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Base/RotationPy.xml b/src/Base/RotationPy.xml index 02dc34ee84..111cfb74c7 100644 --- a/src/Base/RotationPy.xml +++ b/src/Base/RotationPy.xml @@ -48,6 +48,14 @@ + + + + isNull() -> Bool + returns True if the rotation equals the unity matrix + + + The rotation elements (as quaternion) diff --git a/src/Base/RotationPyImp.cpp b/src/Base/RotationPyImp.cpp index 7abede54c7..159952c7e0 100644 --- a/src/Base/RotationPyImp.cpp +++ b/src/Base/RotationPyImp.cpp @@ -144,6 +144,17 @@ PyObject* RotationPy::toEuler(PyObject * args) return Py::new_reference_to(tuple); } +PyObject* RotationPy::isNull(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return NULL; + Base::Rotation rot = * getRotationPtr(); + Base::Rotation nullrot(0,0,0,1); + Base::Rotation nullrotinv(0,0,0,-1); + bool null = (rot == nullrot) | (rot == nullrotinv); + return Py_BuildValue("O", (null ? Py_True : Py_False)); +} + Py::Tuple RotationPy::getQ(void) const { double q0, q1, q2, q3;