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

FXDHMat.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *     H o m o g e n e o u s   D o u b l e - M a t r i x   O p e r a t i o n s   *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1994,2002 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXDHMat.h,v 1.11 2002/03/12 07:11:30 fox Exp $                           *
00023 ********************************************************************************/
00024 #ifndef FXDHMAT_H
00025 #define FXDHMAT_H
00026 
00027 namespace FX {
00028 
00029 /// Homogeneous matrix (double-precision version)
00030 class FXAPI FXDHMat {
00031 protected:
00032   FXDHVec m[4];
00033 public:
00034   /// Constructors
00035   FXDHMat(){}
00036   FXDHMat(const FXDHMat& other);
00037   FXDHMat(FXdouble w);
00038   FXDHMat(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03,
00039           FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13,
00040           FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23,
00041           FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33);
00042   FXDHMat(const FXDHVec& a,const FXDHVec& b,const FXDHVec& c,const FXDHVec& d);
00043 
00044   /// Assignment operators
00045   FXDHMat& operator=(const FXDHMat& other);
00046   FXDHMat& operator=(FXdouble w);
00047   FXDHMat& operator+=(const FXDHMat& w);
00048   FXDHMat& operator-=(const FXDHMat& w);
00049   FXDHMat& operator*=(FXdouble w);
00050   FXDHMat& operator*=(const FXDHMat& w);
00051   FXDHMat& operator/=(FXdouble w);
00052 
00053   /// Return a non-const reference to the ith row
00054   FXDHVec& operator[](FXint i){return m[i];}
00055 
00056   /// Return a const reference to the ith row
00057   const FXDHVec& operator[](FXint i) const {return m[i];}
00058 
00059   /// Conversion
00060   operator FXdouble*(){return m[0];}
00061   operator const FXdouble*() const {return m[0];}
00062 
00063   /// Other operators
00064   friend FXAPI FXDHMat operator+(const FXDHMat& a,const FXDHMat& b);
00065   friend FXAPI FXDHMat operator-(const FXDHMat& a,const FXDHMat& b);
00066   friend FXAPI FXDHMat operator-(const FXDHMat& a);
00067   friend FXAPI FXDHMat operator*(const FXDHMat& a,const FXDHMat& b);
00068   friend FXAPI FXDHMat operator*(FXdouble x,const FXDHMat& a);
00069   friend FXAPI FXDHMat operator*(const FXDHMat& a,FXdouble x);
00070   friend FXAPI FXDHMat operator/(const FXDHMat& a,FXdouble x);
00071   friend FXAPI FXDHMat operator/(FXdouble x,const FXDHMat& a);
00072 
00073   /// Multiply matrix and vector
00074   friend FXAPI FXDHVec operator*(const FXDHVec& v,const FXDHMat& m);
00075   friend FXAPI FXDHVec operator*(const FXDHMat& a,const FXDHVec& v);
00076 
00077   /// Mutiply matrix and vector, for projective matrix
00078   friend FXAPI FXDVec operator*(const FXDVec& v,const FXDHMat& m);
00079   friend FXAPI FXDVec operator*(const FXDHMat& a,const FXDVec& v);
00080 
00081   /// Set to identity matrix
00082   FXDHMat& eye();
00083 
00084   /// Orthographic projection
00085   FXDHMat& ortho(FXdouble left,FXdouble right,FXdouble bottom,FXdouble top,FXdouble hither,FXdouble yon);
00086 
00087   /// Perspective projection
00088   FXDHMat& frustum(FXdouble left,FXdouble right,FXdouble bottom,FXdouble top,FXdouble hither,FXdouble yon);
00089 
00090   /// Multiply by left-hand matrix
00091   FXDHMat& left();
00092 
00093   /// Multiply by rotation about unit-quaternion
00094   FXDHMat& rot(const FXDQuat& q);
00095 
00096   /// Multiply by rotation c,s about axis
00097   FXDHMat& rot(const FXDVec& v,FXdouble c,FXdouble s);
00098 
00099   /// Multiply by rotation of phi about axis
00100   FXDHMat& rot(const FXDVec& v,FXdouble phi);
00101 
00102   /// Multiply by x-rotation
00103   FXDHMat& xrot(FXdouble c,FXdouble s);
00104   FXDHMat& xrot(FXdouble phi);
00105 
00106   /// Multiply by y-rotation
00107   FXDHMat& yrot(FXdouble c,FXdouble s);
00108   FXDHMat& yrot(FXdouble phi);
00109 
00110   /// Multiply by z-rotation
00111   FXDHMat& zrot(FXdouble c,FXdouble s);
00112   FXDHMat& zrot(FXdouble phi);
00113 
00114   /// Look at
00115   FXDHMat& look(const FXDVec& eye,const FXDVec& cntr,const FXDVec& vup);
00116 
00117   /// Multiply by translation
00118   FXDHMat& trans(FXdouble tx,FXdouble ty,FXdouble tz);
00119   FXDHMat& trans(const FXDVec& v);
00120 
00121   /// Multiply by scaling
00122   FXDHMat& scale(FXdouble sx,FXdouble sy,FXdouble sz);
00123   FXDHMat& scale(FXdouble s);
00124   FXDHMat& scale(const FXDVec& v);
00125 
00126   /// Determinant
00127   friend FXAPI FXdouble det(const FXDHMat& m);
00128 
00129   /// Transpose
00130   friend FXAPI FXDHMat transpose(const FXDHMat& m);
00131 
00132   /// Invert
00133   friend FXAPI FXDHMat invert(const FXDHMat& m);
00134 
00135   /// Save to a stream
00136   friend FXAPI FXStream& operator<<(FXStream& store,const FXDHMat& m);
00137 
00138   /// Load from a stream
00139   friend FXAPI FXStream& operator>>(FXStream& store,FXDHMat& m);
00140   };
00141 
00142 }
00143 
00144 #endif