Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CQuat.h

Go to the documentation of this file.
00001 /*
00002  * CQuat.h
00003  * $Id: CQuat.h,v 1.3 2001/11/15 16:54:52 guenth Exp $
00004  *
00005  * Copyright (C) 1999, 2000 R. Klein, Michael Meissner
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * As a special exception to the GPL, the QGLViewer authors (Markus
00022  * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas
00023  * Woerner) give permission to link this program with Qt (non-)commercial
00024  * edition, and distribute the resulting executable, without including
00025  * the source code for the Qt (non-)commercial edition in the source
00026  * distribution.
00027  *
00028  */
00029 
00030 #ifndef CQUAT_H
00031 #define CQUAT_H
00032 
00033 #include <math.h>
00034 #include "GeoGeneric.h"
00035 
00036 
00037 class CV4D;
00038 class CV3D;
00039 class CMat4D;
00040 
00041 
00046 class CQuat
00047 { 
00048    friend class CMat4D;
00049    double w,x,y,z;
00050 public:
00051    // Konstruktoren
00052    CQuat(CMat4D &mat);
00053    CQuat(double qW,double qX, double qY,double qZ);
00054    CQuat(double qW,CV3D &vec);
00055    CQuat(void);
00056 
00057    void setQuat(double qW,double qX, double qY,double qZ) { w=qW; x=qX; y=qY; z=qZ; }
00058 
00059    // Initialisierung
00060    CQuat(const CQuat& );
00061 
00062    // Zuweisung
00063    void operator=(const CQuat& );
00064 
00065    // Addition-Operatoren
00066    CQuat operator+(CQuat&);
00067    CQuat operator-(CQuat&);
00068    CQuat operator-();
00069    
00070    // Multiplikation
00071    CQuat operator*(CQuat&);
00072    CQuat operator*(double&);
00073    friend CQuat operator*(double a,CQuat& q)
00074    { CQuat r; r.w=a*q.w; r.x=a*q.x;r.y=a*q.y;r.z=a*q.z; return r; }
00075 
00076    // Konjugation
00077    CQuat conj();
00078    CQuat inv();
00079  
00080    // Skalarprodukt
00081    double operator|(CQuat&);
00082 
00083    // Norm bzw. Normalisierung von Quaternionen
00084    double norm();
00085    CQuat normalize();
00086  
00087    // Zugriff auf Real- bzw. Imaginaerteil
00088    double re();
00089    CV3D im();
00090 
00091    double xv() const;
00092    double yv() const;
00093    double zv() const;
00094    double wv() const;
00095 
00096    // Beschleunigte Berechnung von Rotationen
00097    CQuat QVQ(CQuat&);
00098 
00099    CV3D rotate(CV3D& vec);
00100 
00101    
00102    // Ausgabe
00103    void print();
00104    /*
00105    Mat getRotMat();
00106    Mat3D getRotMat3D() const;
00107    */
00108 };
00109 
00110 inline 
00111 double 
00112 CQuat :: xv () const
00113 {
00114    return x;
00115 }
00116 
00117 inline 
00118 double 
00119 CQuat :: yv () const
00120 {
00121    return y;
00122 }
00123 
00124 inline 
00125 double 
00126 CQuat :: zv () const
00127 {
00128    return z;
00129 }
00130 
00131 inline 
00132 double 
00133 CQuat :: wv () const
00134 {
00135    return w;
00136 }
00137 
00138 #endif

Generated on Sat Mar 26 17:25:06 2005 for QGLViewer by  doxygen 1.4.0