NLS Engine  v0.1
The Next Logical Step in game engine design.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines
QuatMath.cpp
Go to the documentation of this file.
00001 
00014 #include "QuatMath.h"
00015 
00016 // Standard Includes
00017 
00018 // Library Includes
00019 
00020 // Local Includes
00021 
00022 // Static class member initialization
00023 
00024 // Class methods in the order they are defined within the class header
00025 void RotateVectorByQuaternion(D3DXVECTOR3* result, const D3DXVECTOR3* vec, const D3DXQUATERNION* rot) {
00026   D3DXQUATERNION rotInverse;
00027   D3DXQUATERNION pureQuat (vec->x, vec->y, vec->z, 0.0f);
00028   D3DXQuaternionInverse(&rotInverse, rot);
00029   
00030   pureQuat = rotInverse * pureQuat * *rot;
00031   
00032   result->x = pureQuat.x;
00033   result->y = pureQuat.y;
00034   result->z = pureQuat.z;
00035 }
00036 
00037 void RotateVectorByQuaternion(D3DXVECTOR3* result, const D3DXQUATERNION* rot) {
00038   RotateVectorByQuaternion(result, result, rot);
00039 }