Math/Matrix4: Add Decompose
This commit is contained in:
parent
be8e89b228
commit
bcc10a1ee2
|
|
@ -202,6 +202,7 @@ Nazara Engine:
|
||||||
- Add Flags<E>::Set(Flags) helper method, to enable flags
|
- Add Flags<E>::Set(Flags) helper method, to enable flags
|
||||||
- ⚠ Constraint2D are no longer managed by references and are now handled objects
|
- ⚠ Constraint2D are no longer managed by references and are now handled objects
|
||||||
- ⚠ Removed all Set methods from math classes taking their own type (e.g. Box::Set(Box))
|
- ⚠ Removed all Set methods from math classes taking their own type (e.g. Box::Set(Box))
|
||||||
|
- Added Matrix4::Decompose
|
||||||
|
|
||||||
Nazara Development Kit:
|
Nazara Development Kit:
|
||||||
- Added ImageWidget (#139)
|
- Added ImageWidget (#139)
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ namespace Nz
|
||||||
Matrix4& Concatenate(const Matrix4& matrix);
|
Matrix4& Concatenate(const Matrix4& matrix);
|
||||||
Matrix4& ConcatenateAffine(const Matrix4& matrix);
|
Matrix4& ConcatenateAffine(const Matrix4& matrix);
|
||||||
|
|
||||||
|
void Decompose(Vector3<T>& translation, Quaternion<T>& rotation, Vector3<T>& scale);
|
||||||
|
|
||||||
Vector4<T> GetColumn(unsigned int column) const;
|
Vector4<T> GetColumn(unsigned int column) const;
|
||||||
T GetDeterminant() const;
|
T GetDeterminant() const;
|
||||||
T GetDeterminantAffine() const;
|
T GetDeterminantAffine() const;
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,25 @@ namespace Nz
|
||||||
F(1.0));
|
F(1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Matrix4<T>::Decompose(Vector3<T>& translation, Quaternion<T>& rotation, Vector3<T>& scale)
|
||||||
|
{
|
||||||
|
Matrix4f localMat(*this);
|
||||||
|
|
||||||
|
translation = localMat.GetTranslation();
|
||||||
|
scale = localMat.GetScale();
|
||||||
|
|
||||||
|
Vector3<T> invScale;
|
||||||
|
invScale.x = T(1) / scale.x;
|
||||||
|
invScale.y = T(1) / scale.y;
|
||||||
|
invScale.z = T(1) / scale.z;
|
||||||
|
|
||||||
|
localMat.ApplyScale(invScale);
|
||||||
|
|
||||||
|
rotation = localMat.GetRotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Gets the ith column of the matrix
|
* \brief Gets the ith column of the matrix
|
||||||
* \return Vector4 which is the transformation of this axis
|
* \return Vector4 which is the transformation of this axis
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue