Base: extend Placement/Rotation API

* Add Placement::isSame() and expose to Python
* Add Placement::multRight/Placement::multLeft
* Fix PlacementPy::rotate
* Add Rotation::multRight/Rotation::multLeft
* Add a test feature FeatureTestPlacement for uni tests
* Add unit tests
This commit is contained in:
wmayer
2022-08-09 11:54:05 +02:00
parent b35f66e7c6
commit 00bdd16dff
11 changed files with 217 additions and 20 deletions

View File

@@ -97,6 +97,18 @@ bool Placement::isIdentity() const
return none;
}
bool Placement::isSame(const Placement& p) const
{
return this->_rot.isSame(p._rot) &&
this->_pos.IsEqual(p._pos, 0);
}
bool Placement::isSame(const Placement& p, double tol) const
{
return this->_rot.isSame(p._rot, tol) &&
this->_pos.IsEqual(p._pos, tol);
}
void Placement::invert()
{
this->_rot = this->_rot.inverse();
@@ -126,13 +138,15 @@ bool Placement::operator != (const Placement& that) const
return !(*this == that);
}
/*!
Let this placement be right-multiplied by \a p. Returns reference to
self.
\sa multRight()
*/
Placement & Placement::operator*=(const Placement & p)
{
Base::Vector3d tmp(p._pos);
this->_rot.multVec(tmp, tmp);
this->_pos += tmp;
this->_rot *= p._rot;
return *this;
return multRight(p);
}
Placement Placement::operator*(const Placement & p) const
@@ -154,6 +168,34 @@ Placement Placement::pow(double t, bool shorten) const
return Placement::fromDualQuaternion(this->toDualQuaternion().pow(t, shorten));
}
/*!
Let this placement be right-multiplied by \a p. Returns reference to
self.
\sa multLeft()
*/
Placement& Placement::multRight(const Base::Placement& p)
{
Base::Vector3d tmp(p._pos);
this->_rot.multVec(tmp, tmp);
this->_pos += tmp;
this->_rot.multRight(p._rot);
return *this;
}
/*!
Let this placement be left-multiplied by \a p. Returns reference to
self.
\sa multRight()
*/
Placement& Placement::multLeft(const Base::Placement& p)
{
p.multVec(this->_pos, this->_pos);
this->_rot.multLeft(p._rot);
return *this;
}
void Placement::multVec(const Vector3d & src, Vector3d & dst) const
{
this->_rot.multVec(src, dst);