Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

ctquat.h

00001 /*
00002     Dynamics/Kinematics modeling and simulation library.
00003     Copyright (C) 1999 by Michael Alexander Ewert and Noah Gibbs
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000