Further details on classes like epsilon compare, further unit tests.

This commit is contained in:
Klaus Basan
2013-04-24 01:59:17 +02:00
parent bd53371de4
commit 472521f281
17 changed files with 187 additions and 70 deletions

View File

@@ -7,6 +7,7 @@
#define BLACKMISC_MATHVECTOR3DBASE_H
#include "blackmisc/basestreamstringifier.h"
#include "blackmisc/mathematics.h"
namespace BlackMisc
{
@@ -75,6 +76,26 @@ public:
*/
void setZero();
/*!
* \brief Set zeros
*/
bool isZero() const
{
return this->m_i == 0 && this->m_j == 0 && this->m_k == 0;
}
/*!
* \brief Is identity matrix? Epsilon considered.
* \return
*/
bool isZeroEpsilon() const
{
ImplClass v;
v += (*this);
v.round();
return v.isZero();
}
/*!
* \brief Set zeros
*/
@@ -370,6 +391,18 @@ public:
{
return sqrt(this->lengthSquared());
}
/*!
* \brief Round this vector
*/
void round()
{
const double epsilon = 1E-10;
this->m_i = BlackMisc::Math::CMath::roundEpsilon(this->m_i, epsilon);
this->m_j = BlackMisc::Math::CMath::roundEpsilon(this->m_j, epsilon);
this->m_k = BlackMisc::Math::CMath::roundEpsilon(this->m_k, epsilon);
}
};
} // namespace