CTransform::orthonormalize added

This commit is contained in:
Jack Andersen 2016-03-09 17:47:01 -10:00
parent a76d43d5df
commit b721e09ef5
2 changed files with 13 additions and 4 deletions

View File

@ -110,12 +110,13 @@ public:
return vec[i];
}
inline const CMatrix3f orthonormalized()
inline const CMatrix3f orthonormalized() const
{
CMatrix3f ret;
ret.vec[0] = vec[0].normalized();
ret.vec[1] = vec[2].normalized();
ret.vec[2] = vec[1].normalized();
ret[0] = vec[0].normalized();
ret[2] = ret[0].cross(vec[1]);
ret[2].normalize();
ret[1] = ret[2].cross(ret[0]);
return ret;
}

View File

@ -214,6 +214,14 @@ public:
return ret;
}
inline void orthonormalize()
{
m_basis[0].normalize();
m_basis[2] = m_basis[0].cross(m_basis[1]);
m_basis[2].normalize();
m_basis[1] = m_basis[2].cross(m_basis[0]);
}
CMatrix3f m_basis;
CVector3f m_origin;
};