template math functions in pimathmatrix.h and pimathvector.h and pimathbase.h
add PIMathMatrixT::rotate for matrix 2x2
This commit is contained in:
@@ -425,7 +425,7 @@ public:
|
||||
for (uint k = i; k < Cols; ++k) smat.m[k][j] -= mul * smat.m[k][i];
|
||||
}
|
||||
if (i < Cols - 1) {
|
||||
if (fabs(smat.m[i + 1][i + 1]) < Type(1E-200)) {
|
||||
if (piAbs<Type>(smat.m[i + 1][i + 1]) < Type(1E-200)) {
|
||||
if (ok != 0) *ok = false;
|
||||
return *this;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ public:
|
||||
for (uint k = 0; k < Cols; ++k) mtmp.m[k][j] -= mul * mtmp.m[k][i];
|
||||
}
|
||||
if (i < Cols - 1) {
|
||||
if (fabs(smat.m[i + 1][i + 1]) < Type(1E-200)) {
|
||||
if (piAbs<Type>(smat.m[i + 1][i + 1]) < Type(1E-200)) {
|
||||
if (ok != 0) *ok = false;
|
||||
return *this;
|
||||
}
|
||||
@@ -513,6 +513,18 @@ public:
|
||||
return tm;
|
||||
}
|
||||
|
||||
_CMatrix rotate(Type angle) {
|
||||
static_assert(Rows == 2 && Cols == 2, "Works only with 2x2 matrix");
|
||||
Type c = std::cos(angle);
|
||||
Type s = std::sin(angle);
|
||||
PIMathMatrixT<2u, 2u> tm;
|
||||
tm[0][0] = tm[1][1] = c;
|
||||
tm[0][1] = -s;
|
||||
tm[1][0] = s;
|
||||
*this = *this * tm;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Type m[Rows][Cols];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user