From: <axl...@us...> - 2009-06-04 01:02:54
|
Revision: 306 http://hgengine.svn.sourceforge.net/hgengine/?rev=306&view=rev Author: axlecrusher Date: 2009-06-04 01:02:38 +0000 (Thu, 04 Jun 2009) Log Message: ----------- updates Modified Paths: -------------- Mercury2/src/MQuaternion.cpp Mercury2/src/MQuaternion.h Modified: Mercury2/src/MQuaternion.cpp =================================================================== --- Mercury2/src/MQuaternion.cpp 2009-06-04 00:34:24 UTC (rev 305) +++ Mercury2/src/MQuaternion.cpp 2009-06-04 01:02:38 UTC (rev 306) @@ -16,6 +16,7 @@ m_wxyz[1] = X; m_wxyz[2] = Y; m_wxyz[3] = Z; + *this = this->normalize(); } MQuaternion::MQuaternion(float W, const MercuryVertex& p) @@ -24,13 +25,9 @@ m_wxyz[1] = p[0]; m_wxyz[2] = p[1]; m_wxyz[3] = p[2]; + *this = this->normalize(); } -float & MQuaternion::operator [] (WXYZ i) -{ - return m_wxyz[i]; //haha we won't even get here. -} - void MQuaternion::SetEuler(const MercuryVertex& angles) { float X = angles[0]/2.0f; //roll @@ -50,6 +47,8 @@ m_wxyz[1] = sx*cy*cz-cx*sy*sz;//q2 m_wxyz[2] = cx*sy*cz+sx*cy*sz;//q3 m_wxyz[3] = cx*cy*sz-sx*sy*cz;//q4 + + *this = this->normalize(); } MQuaternion MQuaternion::CreateFromAxisAngle(const MercuryVertex& p, const float radians) @@ -65,9 +64,9 @@ float sn = SIN(radians/2.0f); m_wxyz[0] = COS(radians/2.0f); - m_wxyz[1] = sn * p[0]; - m_wxyz[2] = sn * p[1]; - m_wxyz[3] = sn * p[2]; + m_wxyz[1] = sn * v[0]; + m_wxyz[2] = sn * v[1]; + m_wxyz[3] = sn * v[2]; *this = this->normalize(); } Modified: Mercury2/src/MQuaternion.h =================================================================== --- Mercury2/src/MQuaternion.h 2009-06-04 00:34:24 UTC (rev 305) +++ Mercury2/src/MQuaternion.h 2009-06-04 01:02:38 UTC (rev 306) @@ -25,8 +25,8 @@ void ToAxisAngle(float& angle, float& x, float& y, float& z) const; ///Access a component of the quaternion with the [] operator - float & operator[] ( const WXYZ rhs ); - const float & operator[] ( const WXYZ rhs ) const; + inline float & operator[] ( const WXYZ i ) { return m_wxyz[i]; } + inline const float & operator[] ( const WXYZ i ) const { return m_wxyz[i]; } ///Returns the magnitude float magnitude() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |