00001 /************************************************************************/ 00002 /* Ex Nihlo Engine by Hermanns Christophe */ 00003 /************************************************************************/ 00004 /* This program is free software; you can redistribute it and/or */ 00005 /* modify it under the terms of the GNU General Public License */ 00006 /* as published by the Free Software Foundation; either version 2 */ 00007 /* of the License, or (at your option) any later version. */ 00008 /* */ 00009 /* This program is distributed in the hope that it will be useful, */ 00010 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 00011 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ 00012 /* */ 00013 /* See the GNU General Public License for more details. */ 00014 /* */ 00015 /* You should have received a copy of the GNU General Public License */ 00016 /* along with this program; if not, write to the Free Software */ 00017 /* Foundation, Inc., 59 Temple Place - Suite 330, */ 00018 /* Boston, MA 02111-1307, USA. */ 00019 /* */ 00020 /* If you use a important part of this code please send me a mail */ 00021 /* I just want to see where my code go thks :) */ 00022 /************************************************************************/ 00023 /* For contact : Hermanns Christophe */ 00024 /* Mail : Data@skynet.be */ 00025 /* ICQ : 8030901 */ 00026 /* MSN Messenger: Data_7@hotmail.com */ 00027 /************************************************************************/ 00028 00029 /************************************************************************/ 00030 /* File Name :ExQuaternion.h */ 00031 /* */ 00032 /* Star Date :03/15/2002 */ 00033 /* */ 00034 /* Last Update :03/15/2002 */ 00035 /* */ 00036 /* File Description :Quaternion Class */ 00037 /* Operation on Quaternion */ 00038 /************************************************************************/ 00039 00040 00041 /* $Id: ExQuaternion.h,v 1.2 2002/05/29 00:03:58 binny Exp $ */ 00042 00043 #ifndef __EXQUATERNION_H__ 00044 #define __EXQUATERNION_H__ 00045 00046 #include "ExDefine.h" 00047 #include <math.h> 00048 #include <cmath> 00049 class ExQuaternion 00050 { 00051 public: 00052 //-------------------------------- 00053 //Variable 00054 //-------------------------------- 00055 float qw,qx,qy,qz; 00056 //-------------------------------- 00057 //Constructor // Destructor 00058 //-------------------------------- 00059 ExQuaternion(); 00060 ExQuaternion(float w,float x,float y,float z); 00061 ~ExQuaternion(); 00062 //-------------------------------- 00063 //Methode 00064 //-------------------------------- 00065 void LoadIdentity(void); 00066 void SetQuaternion(float w,float x,float y,float z); 00067 //void SetQuaternion(); 00068 void Normalize(void); 00069 void Conjugate(void); 00070 float GetMagnitude(void); 00071 void SetEuler(float yaw,float pitch,float roll); 00072 00073 // This converts and axis angle rotation to a quaternion 00074 void CreateFromAxisAngle(float X, float Y, float Z, float degree); 00075 00076 // This takes in an array of 16 floats to fill in a 4x4 homogeneous matrix from a quaternion 00077 void CreateMatrix(float *pMatrix); 00078 //-------------------------------- 00079 // Operator 00080 //-------------------------------- 00081 ExQuaternion operator- (const ExQuaternion &Q); 00082 ExQuaternion operator+ (const ExQuaternion &Q); 00083 ExQuaternion operator* (const float scalar); 00084 ExQuaternion operator* (const ExQuaternion &Q); 00085 //-------------------------------- 00086 // friends 00087 //-------------------------------- 00088 friend std::ostream& operator<<(std::ostream& s,const ExQuaternion &q); 00089 }; 00090 00091 #endif // __EXQUATERNION_H__