Added Matrix4::Get[Column|Row]

Former-commit-id: 5dc655f97d8523714c69627e70b3bf8dfdcdb1ae
This commit is contained in:
Lynix 2014-07-28 16:16:32 +02:00
parent 60d5c09c18
commit 454a5b1281
2 changed files with 40 additions and 0 deletions

View File

@ -38,12 +38,14 @@ class NzMatrix4
NzMatrix4& Concatenate(const NzMatrix4& matrix);
NzMatrix4& ConcatenateAffine(const NzMatrix4& matrix);
NzVector4<T> GetColumn(unsigned int column) const;
T GetDeterminant() const;
T GetDeterminantAffine() const;
bool GetInverse(NzMatrix4* dest) const;
bool GetInverseAffine(NzMatrix4* dest) const;
NzQuaternion<T> GetRotation() const;
//NzMatrix3 GetRotationMatrix() const;
NzVector4<T> GetRow(unsigned int row) const;
NzVector3<T> GetScale() const;
NzVector3<T> GetTranslation() const;
void GetTransposed(NzMatrix4* dest) const;

View File

@ -144,6 +144,25 @@ NzMatrix4<T>& NzMatrix4<T>::ConcatenateAffine(const NzMatrix4& matrix)
F(1.0));
}
template<typename T>
NzVector4<T> NzMatrix4<T>::GetColumn(unsigned int column) const
{
///FIXME: Est-ce une bonne idée de gérer la matrice de cette façon ?
#if NAZARA_MATH_SAFE
if (row > 3)
{
NzStringStream ss;
ss << "Row out of range: (" << row << ") > 3";
throw std::out_of_range(ss.ToString());
}
#endif
T* ptr = (&m11) + row*4;
return NzVector4<T>(ptr);
}
template<typename T>
T NzMatrix4<T>::GetDeterminant() const
{
@ -444,6 +463,25 @@ NzQuaternion<T> NzMatrix4<T>::GetRotation() const
return quat;
}
template<typename T>
NzVector4<T> NzMatrix4<T>::GetRow(unsigned int row) const
{
///FIXME: Est-ce une bonne idée de gérer la matrice de cette façon ?
#if NAZARA_MATH_SAFE
if (column > 3)
{
NzStringStream ss;
ss << "Column out of range: (" << column << ") > 3";
throw std::out_of_range(ss.ToString());
}
#endif
T* ptr = &m11;
return NzVector4<T>(ptr[column], ptr[column+4], ptr[column+8], ptr[column+12]);
}
template<typename T>
NzVector3<T> NzMatrix4<T>::GetScale() const
{