Add CTransform::rotateLocal methods

This commit is contained in:
Jack Andersen 2016-02-10 16:35:37 -10:00
parent 698801a160
commit 4a5d21e9b8
1 changed files with 48 additions and 0 deletions

View File

@ -46,6 +46,54 @@ public:
inline void rotate(const CVector3f& euler) { *this = *this * CMatrix3f(CQuaternion(euler)); }
inline void rotateLocalX(float theta)
{
float sinT = sinf(theta);
float cosT = cosf(theta);
Zeus::CVector3f b2 = m_basis[2] * sinT;
Zeus::CVector3f b1 = m_basis[1] * sinT;
Zeus::CVector3f cosV(cosT);
m_basis[1] *= cosV;
m_basis[2] *= cosV;
m_basis[1] += b2;
m_basis[2] -= b1;
}
inline void rotateLocalY(float theta)
{
float sinT = sinf(theta);
float cosT = cosf(theta);
Zeus::CVector3f b0 = m_basis[0] * sinT;
Zeus::CVector3f b2 = m_basis[2] * sinT;
Zeus::CVector3f cosV(cosT);
m_basis[0] *= cosV;
m_basis[2] *= cosV;
m_basis[2] += b0;
m_basis[0] -= b2;
}
inline void rotateLocalZ(float theta)
{
float sinT = sinf(theta);
float cosT = cosf(theta);
Zeus::CVector3f b0 = m_basis[0] * sinT;
Zeus::CVector3f b1 = m_basis[1] * sinT;
Zeus::CVector3f cosV(cosT);
m_basis[0] *= cosV;
m_basis[1] *= cosV;
m_basis[0] += b1;
m_basis[1] -= b0;
}
inline void scaleBy(float factor)
{ CTransform xfrm(CMatrix3f(CVector3f(factor, factor, factor))); *this = *this * xfrm; }