diff --git a/src/Base/Matrix.cpp b/src/Base/Matrix.cpp index bf9b5810d7b1..f27267dbd786 100644 --- a/src/Base/Matrix.cpp +++ b/src/Base/Matrix.cpp @@ -871,3 +871,79 @@ std::string Matrix4D::analyse(void) const } return text; } + +Matrix4D& Matrix4D::Outer(const Vector3f& rV1, const Vector3f& rV2) +{ + setToUnity(); + + dMtrx4D[0][0] = rV1.x * rV2.x; + dMtrx4D[0][1] = rV1.x * rV2.y; + dMtrx4D[0][2] = rV1.x * rV2.z; + + dMtrx4D[1][0] = rV1.y * rV2.x; + dMtrx4D[1][1] = rV1.y * rV2.y; + dMtrx4D[1][2] = rV1.y * rV2.z; + + dMtrx4D[2][0] = rV1.z * rV2.x; + dMtrx4D[2][1] = rV1.z * rV2.y; + dMtrx4D[2][2] = rV1.z * rV2.z; + + return *this; +} + +Matrix4D& Matrix4D::Outer(const Vector3d& rV1, const Vector3d& rV2) +{ + setToUnity(); + + dMtrx4D[0][0] = rV1.x * rV2.x; + dMtrx4D[0][1] = rV1.x * rV2.y; + dMtrx4D[0][2] = rV1.x * rV2.z; + + dMtrx4D[1][0] = rV1.y * rV2.x; + dMtrx4D[1][1] = rV1.y * rV2.y; + dMtrx4D[1][2] = rV1.y * rV2.z; + + dMtrx4D[2][0] = rV1.z * rV2.x; + dMtrx4D[2][1] = rV1.z * rV2.y; + dMtrx4D[2][2] = rV1.z * rV2.z; + + return *this; +} + +Matrix4D& Matrix4D::Hat(const Vector3f& rV) +{ + setToUnity(); + + dMtrx4D[0][0] = 0.0; + dMtrx4D[0][1] = -rV.z; + dMtrx4D[0][2] = rV.y; + + dMtrx4D[1][0] = rV.z; + dMtrx4D[1][1] = 0.0; + dMtrx4D[1][2] = -rV.x; + + dMtrx4D[2][0] = -rV.y; + dMtrx4D[2][1] = rV.x; + dMtrx4D[2][2] = 0.0; + + return *this; +} + +Matrix4D& Matrix4D::Hat(const Vector3d& rV) +{ + setToUnity(); + + dMtrx4D[0][0] = 0.0; + dMtrx4D[0][1] = -rV.z; + dMtrx4D[0][2] = rV.y; + + dMtrx4D[1][0] = rV.z; + dMtrx4D[1][1] = 0.0; + dMtrx4D[1][2] = -rV.x; + + dMtrx4D[2][0] = -rV.y; + dMtrx4D[2][1] = rV.x; + dMtrx4D[2][2] = 0.0; + + return *this; +} diff --git a/src/Base/Matrix.h b/src/Base/Matrix.h index a7986fb6b89f..dc27d349a9fa 100644 --- a/src/Base/Matrix.h +++ b/src/Base/Matrix.h @@ -95,6 +95,12 @@ class BaseExport Matrix4D double determinant() const; /// Analyse the transformation std::string analyse(void) const; + /// Outer product (Dyadic product) + Matrix4D& Outer(const Vector3f& rV1, const Vector3f& rV2); + Matrix4D& Outer(const Vector3d& rV1, const Vector3d& rV2); + /// Hat operator (skew symmetric) + Matrix4D& Hat(const Vector3f& rV); + Matrix4D& Hat(const Vector3d& rV); //@} void getMatrix (double dMtrx[16]) const; diff --git a/src/Base/Vector3D.cpp b/src/Base/Vector3D.cpp index e4b712b4db4f..0d0729013f0b 100644 --- a/src/Base/Vector3D.cpp +++ b/src/Base/Vector3D.cpp @@ -24,7 +24,7 @@ #include "PreCompiled.h" #include "Tools.h" #include "Vector3D.h" -#include "Matrix.h" + using namespace Base; template @@ -192,44 +192,6 @@ Vector3<_Precision> Vector3<_Precision>::Cross(const Vector3<_Precision>& rcVct) return cVctRes; } -template -Matrix4D Vector3<_Precision>::Outer(const Vector3<_Precision>& rcVct) const -{ - Matrix4D mat; - mat[0][0] = x * rcVct.x; - mat[0][1] = x * rcVct.y; - mat[0][2] = x * rcVct.z; - - mat[1][0] = y * rcVct.x; - mat[1][1] = y * rcVct.y; - mat[1][2] = y * rcVct.z; - - mat[2][0] = z * rcVct.x; - mat[2][1] = z * rcVct.y; - mat[2][2] = z * rcVct.z; - - return mat; -} - -template -Matrix4D Vector3<_Precision>::Hat(void) const -{ - Matrix4D mat; - mat[0][0] = 0.0; - mat[0][1] = -z; - mat[0][2] = y; - - mat[1][0] = z; - mat[1][1] = 0.0; - mat[1][2] = -x; - - mat[2][0] = -y; - mat[2][1] = x; - mat[2][2] = 0.0; - - return mat; -} - template bool Vector3<_Precision>::operator != (const Vector3<_Precision>& rcVct) const { diff --git a/src/Base/Vector3D.h b/src/Base/Vector3D.h index 51e213559451..f6816cc5d228 100644 --- a/src/Base/Vector3D.h +++ b/src/Base/Vector3D.h @@ -73,10 +73,6 @@ struct float_traits { static inline float_type maximum() { return DBL_MAX; } }; -class Matrix4D; -//#include - - /** The Vector Base class. */ template class Vector3 @@ -130,10 +126,6 @@ class Vector3 Vector3 operator % (const Vector3<_Precision>& rcVct) const; /// Cross product Vector3 Cross (const Vector3<_Precision>& rcVct) const; - /// Outer product - Matrix4D Outer(const Vector3<_Precision>& rcVct) const; - /// Hat operator (skew symmetric) - Matrix4D Hat(void) const; /// Comparing for inequality bool operator != (const Vector3<_Precision>& rcVct) const;