+ fix == operator of Rotation class, + add method isSame()

This commit is contained in:
wmayer
2016-05-18 18:08:40 +02:00
parent cd312c1f7f
commit f3226a0867
4 changed files with 56 additions and 9 deletions

View File

@@ -294,10 +294,12 @@ Rotation Rotation::operator*(const Rotation & q) const
bool Rotation::operator==(const Rotation & q) const
{
bool equal = true;
for (int i=0; i<4;i++)
equal &= (fabs(this->quat[i] - q.quat[i]) < 0.005 );
return equal;
if (this->quat[0] == q.quat[0] &&
this->quat[1] == q.quat[1] &&
this->quat[2] == q.quat[2] &&
this->quat[3] == q.quat[3])
return true;
return false;
}
bool Rotation::operator!=(const Rotation & q) const
@@ -305,6 +307,16 @@ bool Rotation::operator!=(const Rotation & q) const
return !(*this == q);
}
bool Rotation::isSame(const Rotation& q) const
{
if ((this->quat[0] == q.quat[0] || this->quat[0] == -q.quat[0]) &&
(this->quat[1] == q.quat[1] || this->quat[1] == -q.quat[1]) &&
(this->quat[2] == q.quat[2] || this->quat[2] == -q.quat[2]) &&
(this->quat[3] == q.quat[3] || this->quat[3] == -q.quat[3]))
return true;
return false;
}
void Rotation::multVec(const Vector3d & src, Vector3d & dst) const
{
double x = this->quat[0];