mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-20 20:05:33 +00:00
normalize and affineInverse
added functions for normalize and affineInverse
This commit is contained in:
parent
2cee5f7e10
commit
8f8cc32636
2 changed files with 51 additions and 2 deletions
|
|
@ -653,6 +653,8 @@ public:
|
|||
/// Make this an identity matrix.
|
||||
Matrix<DATA_TYPE, rows, cols>& identity();
|
||||
|
||||
void normalize();
|
||||
|
||||
Matrix<DATA_TYPE, rows, cols>& set(const EulerF& e);
|
||||
|
||||
Matrix(const EulerF& e, const Point3F p);
|
||||
|
|
@ -730,8 +732,14 @@ public:
|
|||
void mul(Box3F& box) const;
|
||||
|
||||
// ------ Getters ------
|
||||
// col * rows + row
|
||||
// static U32 idx(U32 i, U32 j) { return (i * rows + j); }
|
||||
bool isAffine() const;
|
||||
bool isIdentity() const;
|
||||
/// Take inverse of matrix assuming it is affine (rotation,
|
||||
/// scale, sheer, translation only).
|
||||
Matrix<DATA_TYPE, rows, cols>& affineInverse();
|
||||
|
||||
Point3F getScale() const;
|
||||
|
||||
EulerF toEuler() const;
|
||||
|
|
@ -906,6 +914,26 @@ inline Matrix<DATA_TYPE, rows, cols>& Matrix<DATA_TYPE, rows, cols>::identity()
|
|||
return (*this);
|
||||
}
|
||||
|
||||
template<typename DATA_TYPE, U32 rows, U32 cols>
|
||||
inline void Matrix<DATA_TYPE, rows, cols>::normalize()
|
||||
{
|
||||
AssertFatal(rows >= 3 && cols >= 3, "Normalize can only be applied 3x3 or more");
|
||||
Point3F col0, col1, col2;
|
||||
getColumn(0, &col0);
|
||||
getColumn(1, &col1);
|
||||
|
||||
mCross(col0, col1, &col2);
|
||||
mCross(col2, col0, &col1);
|
||||
|
||||
col0.normalize();
|
||||
col1.normalize();
|
||||
col2.normalize();
|
||||
|
||||
setColumn(0, col0);
|
||||
setColumn(1, col1);
|
||||
setColumn(2, col2);
|
||||
}
|
||||
|
||||
template<typename DATA_TYPE, U32 rows, U32 cols>
|
||||
inline Matrix<DATA_TYPE, rows, cols>& Matrix<DATA_TYPE, rows, cols>::scale(const Point3F& s)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue