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

CMat4D.h

Go to the documentation of this file.
00001 /*
00002  * CMat4D.h
00003  * $Id: CMat4D.h,v 1.2 2001/08/09 09:51:38 mjanich 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  */
00022 
00023 //  Description : Class CMat4D
00024 //  Purpose     : Provides funcionality of a matrix
00025 
00026 
00027 #ifndef __CMAT4D_H_
00028 #define __CMAT4D_H_
00029 
00030 
00031 // Qt
00033 
00034 
00035 // System
00037 #include <iostream.h>
00038 #include <math.h>
00039 #include <string.h>
00040 
00041 
00042 // Own
00044 #include "CV4D.h"
00045 #include "CQuat.h"
00046 #include "CP4D.h"
00047 
00048 
00049 
00051 
00074 class CMat4D {
00075 
00076 public:
00078   CMat4D(void);
00079 
00083   CMat4D(const CV4D&, const CV4D&, const CV4D&, const CV4D&);
00084 
00088   CMat4D(const double*);
00089 
00091   CMat4D(double, double, double, double, double, double, double, double,
00092          double, double, double, double, double, double, double, double);
00093 
00095   CMat4D(const CMat4D&);
00096 
00098   static CMat4D PIdentity(void);
00099 
00102   static CMat4D PTranslate(const CV4D&);
00103 
00105   static CMat4D PTranslate(const CV3D&);
00106 
00108   static CMat4D PTranslate(double, double, double);
00109 
00112   static CMat4D PScale(const CV4D&);
00113 
00115   static CMat4D PScale(const CV3D&);
00116 
00118   static CMat4D PScale(double, double, double);
00119 
00123   static CMat4D PRotate(const CV4D&, double);
00124 
00127   static CMat4D PRotate(const CV3D&, double);
00128 
00130   static CMat4D PRotate(CQuat&);
00131 
00133   ~CMat4D(void);
00134 
00135 
00136 
00138   // OVERLOADED OPERATORS //
00140 
00142   const CMat4D& operator=(const CMat4D&);
00143 
00145   const CMat4D& operator=(const double a);
00146 
00148   CMat4D& operator+=(const CMat4D &m);
00149 
00150   /* Substract matrix from this matrix */
00151   CMat4D& operator-=(const CMat4D &m);
00152 
00154   CMat4D& operator*=(const CMat4D&);
00155 
00156 
00158   CMat4D operator+(const CMat4D&) const;
00159 
00161   CMat4D operator-(const CMat4D&) const;
00162 
00164   CMat4D operator*(const CMat4D &m) const;
00165 
00167   CMat4D operator*(double scalar) const;
00168 
00170   bool operator == (const CMat4D &m) const;
00171 
00173   bool operator != (const CMat4D &m) const;
00174 
00175 
00177   double operator()(int i,int j) const;
00178 
00180   CV4D operator[](int i) const;
00181 
00183   CV4D operator()(int j) const;
00184 
00185 
00187   friend CV4D operator*(const CMat4D&, const CV4D&);
00188 
00190   friend CP4D operator*(const CMat4D&, const CP4D&);
00191 
00193   friend CMat4D operator*(double, const CMat4D&);
00194 
00196   friend CMat4D operator*(const CMat4D& M, double rdFactor) { return rdFactor*M; };
00197  
00198 
00199 
00201   // METHODS //
00203  
00205   const double *getArray() { return m_ardValues; };
00206 
00208   void clear(void);
00209 
00213   void setValues(double* field);
00214  
00216   double getCoeff(int i,int j) const;
00217 
00219   void setCoeff(int i,int j, double value);
00220  
00222   CMat4D getTransposed(void) const;
00223 
00224   // Inverted
00225   CMat4D getInverted(void) const;
00226 
00228   bool invert(void);
00229 
00231   void transpose(void);
00232 
00234   void print(void);
00235 
00237   friend ostream& operator << (ostream& s, const CMat4D &m );
00238 
00240   void setIdentity( void );
00241 
00243   CV4D getRow(int);
00244 
00246   CV4D getCol(int);
00247 
00249   void setRow(int nRow, const CV4D&);
00250  
00252   void setCol(int nCol, const CV4D&);
00254   void setRows(const CV4D&, const CV4D&, const CV4D&, const CV4D&);
00255 
00257   void setCols(const CV4D&, const CV4D&, const CV4D&, const CV4D&);
00258 
00262   void setScaling(const CV4D&);
00263 
00267   void setScaling(const CV3D&);
00268 
00272   void setScaling(double, double, double);
00273 
00277   void setTranslation(const CV4D&);
00278 
00282   void setTranslation(const CV3D&);
00283 
00287   void setTranslation(double, double, double);
00288 
00290   void setRotation(CV4D&, double);
00291 
00293   void setRotation(CV3D&, double);
00294 
00296   void setRotation(CQuat&);
00297 
00298 
00299 
00300  private:
00302   double*  get1DField(void);
00303 
00305   double** get2DField(void);
00306 
00307   double m_ardValues[16];  // In the array the values of the matrix are saved by columns.
00308 };
00309 
00310 #endif // __CMAT4D_H_

Generated at Thu Oct 4 17:17:25 2001 for QGLViewer by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001