Math/Matrix4: Add GetSquaredScale() method

Former-commit-id: c1ce74560b735dbcd5a4c377a7577a9d2c1bae09
This commit is contained in:
Lynix 2015-05-26 23:38:06 +02:00
parent 6f06383ab0
commit b0f418c481
2 changed files with 11 additions and 3 deletions

View File

@ -49,6 +49,7 @@ class NzMatrix4
//NzMatrix3 GetRotationMatrix() const; //NzMatrix3 GetRotationMatrix() const;
NzVector4<T> GetRow(unsigned int row) const; NzVector4<T> GetRow(unsigned int row) const;
NzVector3<T> GetScale() const; NzVector3<T> GetScale() const;
NzVector3<T> GetSquaredScale() const;
NzVector3<T> GetTranslation() const; NzVector3<T> GetTranslation() const;
void GetTransposed(NzMatrix4* dest) const; void GetTransposed(NzMatrix4* dest) const;

View File

@ -485,9 +485,16 @@ NzVector4<T> NzMatrix4<T>::GetRow(unsigned int row) const
template<typename T> template<typename T>
NzVector3<T> NzMatrix4<T>::GetScale() const NzVector3<T> NzMatrix4<T>::GetScale() const
{ {
return NzVector3<T>(std::sqrt(m11*m11 + m21*m21 + m31*m31), NzVector3<T> squaredScale = GetSquaredScale();
std::sqrt(m12*m12 + m22*m22 + m32*m32), return NzVector3<T>(std::sqrt(squaredScale.x), std::sqrt(squaredScale.y), std::sqrt(squaredScale.z));
std::sqrt(m13*m13 + m23*m23 + m33*m33)); }
template<typename T>
NzVector3<T> NzMatrix4<T>::GetSquaredScale() const
{
return NzVector3<T>(m11*m11 + m21*m21 + m31*m31,
m12*m12 + m22*m22 + m32*m32,
m13*m13 + m23*m23 + m33*m33);
} }
template<typename T> template<typename T>