Added 0000650 - Placement.isNull() function

This commit is contained in:
Yorik van Havre
2012-03-28 10:39:10 -03:00
parent 4903e3876a
commit a5e5389745
2 changed files with 31 additions and 10 deletions

View File

@@ -83,9 +83,9 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* d;
double angle;
if (PyArg_ParseTuple(args, "O!O!d", &(Base::VectorPy::Type), &o,
&(Base::VectorPy::Type), &d, &angle)) {
// NOTE: The first parameter defines the translation, the second the rotation axis
// and the last parameter defines the rotation angle in degree.
&(Base::VectorPy::Type), &d, &angle)) {
// NOTE: The first parameter defines the translation, the second the rotation axis
// and the last parameter defines the rotation angle in degree.
Base::Rotation rot(static_cast<Base::VectorPy*>(d)->value(), angle/180.0*D_PI);
*getPlacementPtr() = Base::Placement(static_cast<Base::VectorPy*>(o)->value(),rot);
return 0;
@@ -145,13 +145,13 @@ PyObject* PlacementPy::multVec(PyObject * args)
getPlacementPtr()->multVec(pnt, pnt);
return new VectorPy(new Vector3d(pnt));
}
PyObject* PlacementPy::copy(PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
return new PlacementPy(new Placement(*getPlacementPtr()));
}
PyObject* PlacementPy::copy(PyObject * args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
return new PlacementPy(new Placement(*getPlacementPtr()));
}
PyObject* PlacementPy::toMatrix(PyObject * args)
{
@@ -169,6 +169,19 @@ PyObject* PlacementPy::inverse(PyObject * args)
return new PlacementPy(new Placement(p));
}
PyObject* PlacementPy::isNull(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
Base::Vector3d pos = getPlacementPtr()->getPosition();
Base::Rotation rot = getPlacementPtr()->getRotation();
Base::Vector3d nullvec(0,0,0);
Base::Rotation nullrot(0,0,0,1);
Base::Rotation nullrotinv(0,0,0,-1);
bool null = (pos == nullvec) & ((rot == nullrot) | (rot == nullrotinv));
return Py_BuildValue("O", (null ? Py_True : Py_False));
}
Py::Object PlacementPy::getBase(void) const
{
return Py::Vector(getPlacementPtr()->getPosition());