diff --git a/libs/main/math/pimathmatrix.h b/libs/main/math/pimathmatrix.h index 783c1a6a..399afdd6 100644 --- a/libs/main/math/pimathmatrix.h +++ b/libs/main/math/pimathmatrix.h @@ -63,9 +63,9 @@ class PIP_EXPORT PIMathMatrixT { typedef PIMathMatrixT _CMatrixI; typedef PIMathVectorT _CMCol; typedef PIMathVectorT _CMRow; - static_assert(std::is_arithmetic::value, "Type must be arithmetic"); - static_assert(Rows > 0, "Row count must be > 0"); - static_assert(Cols > 0, "Column count must be > 0"); + static_assert(std::is_arithmetic::value, "Type must be arithmetic"); + static_assert(Rows > 0, "Row count must be > 0"); + static_assert(Cols > 0, "Column count must be > 0"); public: PIMathMatrixT() {resize(Rows, Cols);} PIMathMatrixT(const PIVector & val) {resize(Rows, Cols); int i = 0; PIMM_FOR_I_WB(r, c) m[r][c] = val[i++];} @@ -86,7 +86,7 @@ public: static _CMatrix filled(const Type & v) {_CMatrix tm; PIMM_FOR_WB(r, c) tm.m[r][c] = v; return tm;} /** - * @brief Rotation the matrix by an "angle" + * @brief Rotation the matrix by an "angle". Works only with 2x2 matrix, else return _CMatrix * * @param angle is the angle of rotation of the matrix * @return rotated matrix @@ -94,7 +94,7 @@ public: static _CMatrix rotation(double angle) {return _CMatrix();} /** - * @brief Rotation of the matrix by an "angle" along the X axis + * @brief Rotation of the matrix by an "angle" along the X axis. Works only with 3x3 matrix, else return _CMatrix * * @param angle is the angle of rotation of the matrix along the X axis * @return rotated matrix @@ -102,7 +102,7 @@ public: static _CMatrix rotationX(double angle) {return _CMatrix();} /** - * @brief Rotation of the matrix by an "angle" along the Y axis + * @brief Rotation of the matrix by an "angle" along the Y axis. Works only with 3x3 matrix, else return _CMatrix * * @param angle is the angle of rotation of the matrix along the Y axis * @return rotated matrix @@ -110,7 +110,7 @@ public: static _CMatrix rotationY(double angle) {return _CMatrix();} /** - * @brief Rotation of the matrix by an "angle" along the Z axis + * @brief Rotation of the matrix by an "angle" along the Z axis. Works only with 3x3 matrix, else return _CMatrix * * @param angle is the angle of rotation of the matrix along the Z axis * @return rotated matrix @@ -118,7 +118,7 @@ public: static _CMatrix rotationZ(double angle) {return _CMatrix();} /** - * @brief Scaling the matrix along the X axis by the value "factor" + * @brief Scaling the matrix along the X axis by the value "factor". Works only with 3x3 and 2x2 matrix, else return _CMatrix * * @param factor is the value of scaling by X axis * @return rotated matrix @@ -126,7 +126,7 @@ public: static _CMatrix scaleX(double factor) {return _CMatrix();} /** - * @brief Scaling the matrix along the Y axis by the value "factor" + * @brief Scaling the matrix along the Y axis by the value "factor". Works only with 3x3 and 2x2 matrix, else return _CMatrix * * @param factor is the value of scaling by Y axis * @return rotated matrix @@ -134,7 +134,7 @@ public: static _CMatrix scaleY(double factor) {return _CMatrix();} /** - * @brief Scaling the matrix along the Z axis by the value "factor" + * @brief Scaling the matrix along the Z axis by the value "factor". Works only with 3x3 matrix, else return _CMatrix * * @param factor is the value of scaling by Z axis * @return rotated matrix diff --git a/tests/concurrent/testutil.h b/tests/concurrent/testutil.h index 9df146ba..7c3c15c7 100644 --- a/tests/concurrent/testutil.h +++ b/tests/concurrent/testutil.h @@ -3,7 +3,6 @@ #include "pithread.h" #include -#include "pistring.h" /** * Minimum wait thread start, switch context or another interthread communication action time. Increase it if tests @@ -58,5 +57,4 @@ public: } }; - #endif //AWRCANFLASHER_TESTUTIL_H diff --git a/tests/math/testpimathmatrixt.cpp b/tests/math/testpimathmatrixt.cpp index 38976bf8..2d68d131 100644 --- a/tests/math/testpimathmatrixt.cpp +++ b/tests/math/testpimathmatrixt.cpp @@ -674,24 +674,6 @@ TEST(PIMathMatrixT_Test, transposed) ASSERT_TRUE(b); } -TEST(PIMathMatrixT_Test, rotation) -{ - double angle = 1.0; - bool b; - PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::rotation(angle); - double c = cos(angle); - double s = sin(angle); - if((c == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (-s == matrix.at(0u,1u)) && (s == matrix.at(1u,0u))) - { - b = true; - } - else - { - b = false; - } - ASSERT_TRUE(b); -} - TEST(PIMathMatrixT_Test, scaleX_two) { double factor = 5.64; @@ -726,6 +708,31 @@ TEST(PIMathMatrixT_Test, scaleY_two) ASSERT_TRUE(b); } +TEST(PIMathMatrixT_Test, rotation_2x2) +{ + double angle = 1.0; + bool b; + PIMathMatrixT<2u, 2u, double> matrix = PIMathMatrixT<2u, 2u, double>::rotation(angle); + double c = cos(angle); + double s = sin(angle); + if((c == matrix.at(1u,1u)) && (c == matrix.at(0u,0u)) && (-s == matrix.at(0u,1u)) && (s == matrix.at(1u,0u))) + { + b = true; + } + else + { + b = false; + } + ASSERT_TRUE(b); +} + +TEST(PIMathMatrixT_Test, rotation_3x3) +{ + double angle = 1.0; + PIMathMatrixT<3u, 3u, double> matrix = PIMathMatrixT<3u, 3u, double>::rotation(angle); + ASSERT_TRUE(cmpMatrixWithValue(matrix, 0.0)); +} + TEST(PIMathMatrixT_Test, rotationX) { double angle = 1.0; @@ -831,3 +838,4 @@ TEST(PIMathMatrixT_Test, scaleZ_three) ASSERT_TRUE(b); } +