//------------------------------- // //------------------------------- void Vector3::GetQuaternion( Quaternion& qRot ) { Vector3 vDir; vDir.x = x; vDir.y = y; vDir.z = z; vDir.Normalize(); vDir *= -1; Matrix44 matWorld; matWorld.SetWorld( Vector3( 0.0F, 0.0F, 0.0F ), vDir, Vector3( 0.0F, 0.0F, 1.0F ) ); qRot = matWorld.GetQuaternion(); } //Vector3::GetQuaternion
//------------------------------- // //------------------------------- Quaternion Vector3::GetQuaternion() { Vector3 vDummy; vDummy.x = x; vDummy.y = y; vDummy.z = z; if( x == 0 && y == 0 ) { Quaternion qRot; qRot.SetRotationZ( ANGLE( 0 ) ); return qRot; } //if vDummy.Normalize(); vDummy *= -1; Matrix44 matWorld; matWorld.SetWorld( vInit, vDummy, vUp ); return matWorld.GetQuaternion(); } //Vector3::GetQuaternion
//-------------------------------- // //-------------------------------- void Quaternion::SetOrientation( const Vector3& vDir, const Vector3& vUp ) { Matrix44 matWorld; matWorld.SetWorld( Vector3( 0.0F, 0.0F, 0.0F ), vDir, vUp ); *this = matWorld.GetQuaternion(); } //Quaternion::SetOrientation