Added Matrix4::GetDeterminantAffine
Former-commit-id: 404098cc552509039c38e7449b167dbab0385008
This commit is contained in:
parent
a65a6f14b5
commit
c7fdf25432
|
|
@ -37,6 +37,7 @@ class NzMatrix4
|
||||||
NzMatrix4& ConcatenateAffine(const NzMatrix4& matrix);
|
NzMatrix4& ConcatenateAffine(const NzMatrix4& matrix);
|
||||||
|
|
||||||
T GetDeterminant() const;
|
T GetDeterminant() const;
|
||||||
|
T GetDeterminantAffine() const;
|
||||||
bool GetInverse(NzMatrix4* dest) const;
|
bool GetInverse(NzMatrix4* dest) const;
|
||||||
bool GetInverseAffine(NzMatrix4* dest) const;
|
bool GetInverseAffine(NzMatrix4* dest) const;
|
||||||
NzQuaternion<T> GetRotation() const;
|
NzQuaternion<T> GetRotation() const;
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,16 @@ T NzMatrix4<T>::GetDeterminant() const
|
||||||
return m11*A - m21*B + m31*C - m41*D;
|
return m11*A - m21*B + m31*C - m41*D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T NzMatrix4<T>::GetDeterminantAffine() const
|
||||||
|
{
|
||||||
|
T A = m22*m33 - m32*m23;
|
||||||
|
T B = m12*m33 - m32*m13;
|
||||||
|
T C = m12*m23 - m22*m13;
|
||||||
|
|
||||||
|
return m11*A - m21*B + m31*C;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool NzMatrix4<T>::GetInverse(NzMatrix4* dest) const
|
bool NzMatrix4<T>::GetInverse(NzMatrix4* dest) const
|
||||||
{
|
{
|
||||||
|
|
@ -286,7 +296,13 @@ template<typename T>
|
||||||
bool NzMatrix4<T>::GetInverseAffine(NzMatrix4* dest) const
|
bool NzMatrix4<T>::GetInverseAffine(NzMatrix4* dest) const
|
||||||
{
|
{
|
||||||
///DOC: Il est possible d'appeler cette méthode avec la même matrice en argument qu'en appelant
|
///DOC: Il est possible d'appeler cette méthode avec la même matrice en argument qu'en appelant
|
||||||
#ifdef NAZARA_DEBUG
|
#if NAZARA_MATH_SAFE
|
||||||
|
if (!IsAffine())
|
||||||
|
{
|
||||||
|
NazaraError("Matrix is not affine");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!dest)
|
if (!dest)
|
||||||
{
|
{
|
||||||
NazaraError("Destination matrix must be valid");
|
NazaraError("Destination matrix must be valid");
|
||||||
|
|
@ -294,7 +310,7 @@ bool NzMatrix4<T>::GetInverseAffine(NzMatrix4* dest) const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
T det = GetDeterminant();
|
T det = GetDeterminantAffine();
|
||||||
if (!NzNumberEquals(det, F(0.0)))
|
if (!NzNumberEquals(det, F(0.0)))
|
||||||
{
|
{
|
||||||
// http://stackoverflow.com/questions/1148309/inverting-a-4x4-matrix
|
// http://stackoverflow.com/questions/1148309/inverting-a-4x4-matrix
|
||||||
|
|
@ -432,17 +448,6 @@ NzMatrix4<T>& NzMatrix4<T>::Inverse(bool* succeeded)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzMatrix4<T>& NzMatrix4<T>::InverseAffine(bool* succeeded)
|
NzMatrix4<T>& NzMatrix4<T>::InverseAffine(bool* succeeded)
|
||||||
{
|
{
|
||||||
#if NAZARA_MATH_SAFE
|
|
||||||
if (!IsAffine())
|
|
||||||
{
|
|
||||||
NazaraError("Matrix not affine");
|
|
||||||
if (succeeded)
|
|
||||||
*succeeded = false;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool result = GetInverseAffine(this);
|
bool result = GetInverseAffine(this);
|
||||||
if (succeeded)
|
if (succeeded)
|
||||||
*succeeded = result;
|
*succeeded = result;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue