add method Placement::isIdentity

This commit is contained in:
wmayer
2018-09-05 21:19:16 +02:00
parent 363de2f7da
commit 79938b119f
3 changed files with 10 additions and 5 deletions

View File

@@ -79,6 +79,13 @@ void Placement::fromMatrix(const Base::Matrix4D& matrix)
this->_pos.z = matrix[2][3];
}
bool Placement::isIdentity() const
{
Base::Vector3d nullvec(0,0,0);
bool none = (this->_pos == nullvec) && (this->_rot.isIdentity());
return none;
}
void Placement::invert()
{
this->_rot = this->_rot.inverse();

View File

@@ -55,6 +55,7 @@ public:
void setPosition(const Vector3d& Pos){_pos=Pos;}
void setRotation(const Rotation& Rot) {_rot = Rot;}
bool isIdentity() const;
void invert();
Placement inverse() const;
void move(const Vector3d& MovVec);

View File

@@ -204,11 +204,8 @@ PyObject* PlacementPy::isIdentity(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
Base::Vector3d nullvec(0,0,0);
Base::Vector3d pos = getPlacementPtr()->getPosition();
Base::Rotation rot = getPlacementPtr()->getRotation();
bool null = (pos == nullvec) && (rot.isIdentity());
return Py_BuildValue("O", (null ? Py_True : Py_False));
bool none = getPlacementPtr()->isIdentity();
return Py_BuildValue("O", (none ? Py_True : Py_False));
}
Py::Object PlacementPy::getBase(void) const