Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CMat4D.h

Go to the documentation of this file.
00001 /*
00002  * CMat4D.h
00003  * $Id: CMat4D.h,v 1.3 2001/11/15 16:54:52 guenth Exp $
00004  *
00005  * Copyright (C) 1999, 2000 Michael Meissner, Markus Janich, Rainer Jaeger
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 //  Description : Class CMat4D
00031 //  Purpose     : Provides funcionality of a matrix
00032 
00033 
00034 #ifndef __CMAT4D_H_
00035 #define __CMAT4D_H_
00036 
00037 
00038 // Qt
00040 
00041 
00042 // System
00044 #include <iostream.h>
00045 #include <math.h>
00046 #include <string.h>
00047 
00048 
00049 // Own
00051 #include "CV4D.h"
00052 #include "CQuat.h"
00053 #include "CP4D.h"
00054 
00055 
00056 
00058 
00081 class CMat4D {
00082 
00083 public:
00085   CMat4D(void);
00086 
00090   CMat4D(const CV4D&, const CV4D&, const CV4D&, const CV4D&);
00091 
00095   CMat4D(const double*);
00096 
00098   CMat4D(double, double, double, double, double, double, double, double,
00099          double, double, double, double, double, double, double, double);
00100 
00102   CMat4D(const CMat4D&);
00103 
00105   static CMat4D PIdentity(void);
00106 
00109   static CMat4D PTranslate(const CV4D&);
00110 
00112   static CMat4D PTranslate(const CV3D&);
00113 
00115   static CMat4D PTranslate(double, double, double);
00116 
00119   static CMat4D PScale(const CV4D&);
00120 
00122   static CMat4D PScale(const CV3D&);
00123 
00125   static CMat4D PScale(double, double, double);
00126 
00130   static CMat4D PRotate(const CV4D&, double);
00131 
00134   static CMat4D PRotate(const CV3D&, double);
00135 
00137   static CMat4D PRotate(CQuat&);
00138 
00140   ~CMat4D(void);
00141 
00142 
00143 
00145   // OVERLOADED OPERATORS //
00147 
00149   const CMat4D& operator=(const CMat4D&);
00150 
00152   const CMat4D& operator=(const double a);
00153 
00155   CMat4D& operator+=(const CMat4D &m);
00156 
00157   /* Substract matrix from this matrix */
00158   CMat4D& operator-=(const CMat4D &m);
00159 
00161   CMat4D& operator*=(const CMat4D&);
00162 
00163 
00165   CMat4D operator+(const CMat4D&) const;
00166 
00168   CMat4D operator-(const CMat4D&) const;
00169 
00171   CMat4D operator*(const CMat4D &m) const;
00172 
00174   CMat4D operator*(double scalar) const;
00175 
00177   bool operator == (const CMat4D &m) const;
00178 
00180   bool operator != (const CMat4D &m) const;
00181 
00182 
00184   double operator()(int i,int j) const;
00185 
00187   CV4D operator[](int i) const;
00188 
00190   CV4D operator()(int j) const;
00191 
00192 
00194   friend CV4D operator*(const CMat4D&, const CV4D&);
00195 
00197   friend CP4D operator*(const CMat4D&, const CP4D&);
00198 
00200   friend CMat4D operator*(double, const CMat4D&);
00201 
00203   friend CMat4D operator*(const CMat4D& M, double rdFactor) { return rdFactor*M; };
00204  
00205 
00206 
00208   // METHODS //
00210  
00212   const double *getArray() { return m_ardValues; };
00213 
00215   void clear(void);
00216 
00220   void setValues(double* field);
00221  
00223   double getCoeff(int i,int j) const;
00224 
00226   void setCoeff(int i,int j, double value);
00227  
00229   CMat4D getTransposed(void) const;
00230 
00231   // Inverted
00232   CMat4D getInverted(void) const;
00233 
00235   bool invert(void);
00236 
00238   void transpose(void);
00239 
00241   void print(void);
00242 
00244   friend ostream& operator << (ostream& s, const CMat4D &m );
00245 
00247   void setIdentity( void );
00248 
00250   CV4D getRow(int);
00251 
00253   CV4D getCol(int);
00254 
00256   void setRow(int nRow, const CV4D&);
00257  
00259   void setCol(int nCol, const CV4D&);
00261   void setRows(const CV4D&, const CV4D&, const CV4D&, const CV4D&);
00262 
00264   void setCols(const CV4D&, const CV4D&, const CV4D&, const CV4D&);
00265 
00269   void setScaling(const CV4D&);
00270 
00274   void setScaling(const CV3D&);
00275 
00279   void setScaling(double, double, double);
00280 
00284   void setTranslation(const CV4D&);
00285 
00289   void setTranslation(const CV3D&);
00290 
00294   void setTranslation(double, double, double);
00295 
00297   void setRotation(CV4D&, double);
00298 
00300   void setRotation(CV3D&, double);
00301 
00303   void setRotation(CQuat&);
00304 
00305 
00306 
00307  private:
00309   double*  get1DField(void);
00310 
00312   double** get2DField(void);
00313 
00314   double m_ardValues[16];  // In the array the values of the matrix are saved by columns.
00315 };
00316 
00317 #endif // __CMAT4D_H_

Generated on Wed Mar 5 18:23:25 2003 for QGLViewer by doxygen1.3-rc3