mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
Further details on classes like epsilon compare, further unit tests.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user