00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #ifndef __CTQUATERNION_H__
00022 #define __CTQUATERNION_H__
00023 
00024 #include "csgeom/quaterni.h"
00025 #include "csphyzik/ctvector.h"
00026 #include "csphyzik/ctmatrix.h"
00027 
00028 class ctQuaternion : public csQuaternion {
00029  public:
00030   ctQuaternion (float r, float x, float y, float z)
00031     : csQuaternion ( r, x, y, z ) {}
00032 
00033   ctQuaternion (ctVector3 x)
00034     : csQuaternion ( csVector3(x[0], x[1], x[2]) ) {}
00035 
00036   ctQuaternion(csVector3 x)
00037     : csQuaternion ( csVector3(x[0], x[1], x[2]) ) {}
00038 
00039   ctQuaternion(csQuaternion q)
00040     : csQuaternion ( q.r, q.x, q.y, q.z ) {}
00041 
00042   ctQuaternion () {}
00043   ~ctQuaternion () {}
00044 
00045   ctMatrix3 to_matrix ();
00046   void from_matrix (ctMatrix3& M);
00047 
00049   ctVector3 Rotate (ctVector3 pt)
00050   {
00051     ctQuaternion p (pt);
00052     ctQuaternion qConj (r, -x, -y, -z);
00053 
00054     p = ctQuaternion (*this * p);
00055     p *= qConj;
00056     return ctVector3 (p.x, p.y, p.z);
00057   }
00058 };
00059 
00060 #endif // __CTQUATERNION_H__
00061