![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
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.9 2002/01/18 22:42:51 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXDHMAT_H 00025 #define FXDHMAT_H 00026 00027 00028 /// Homogeneous matrix (double-precision version) 00029 class FXAPI FXDHMat { 00030 protected: 00031 FXDHVec m[4]; 00032 public: 00033 /// Constructors 00034 FXDHMat(){} 00035 FXDHMat(const FXDHMat& other); 00036 FXDHMat(FXdouble w); 00037 FXDHMat(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03, 00038 FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13, 00039 FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23, 00040 FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33); 00041 FXDHMat(const FXDHVec& a,const FXDHVec& b,const FXDHVec& c,const FXDHVec& d); 00042 00043 /// Assignment operators 00044 FXDHMat& operator=(const FXDHMat& other); 00045 FXDHMat& operator=(FXdouble w); 00046 FXDHMat& operator+=(const FXDHMat& w); 00047 FXDHMat& operator-=(const FXDHMat& w); 00048 FXDHMat& operator*=(FXdouble w); 00049 FXDHMat& operator*=(const FXDHMat& w); 00050 FXDHMat& operator/=(FXdouble w); 00051 00052 /// Return a non-const reference to the ith row 00053 FXDHVec& operator[](FXint i){return m[i];} 00054 00055 /// Return a const reference to the ith row 00056 const FXDHVec& operator[](FXint i) const {return m[i];} 00057 00058 /// Conversion 00059 operator FXdouble*(){return m[0];} 00060 operator const FXdouble*() const {return m[0];} 00061 00062 /// Other operators 00063 friend FXAPI FXDHMat operator+(const FXDHMat& a,const FXDHMat& b); 00064 friend FXAPI FXDHMat operator-(const FXDHMat& a,const FXDHMat& b); 00065 friend FXAPI FXDHMat operator-(const FXDHMat& a); 00066 friend FXAPI FXDHMat operator*(const FXDHMat& a,const FXDHMat& b); 00067 friend FXAPI FXDHMat operator*(FXdouble x,const FXDHMat& a); 00068 friend FXAPI FXDHMat operator*(const FXDHMat& a,FXdouble x); 00069 friend FXAPI FXDHMat operator/(const FXDHMat& a,FXdouble x); 00070 friend FXAPI FXDHMat operator/(FXdouble x,const FXDHMat& a); 00071 00072 /// Multiply matrix and vector 00073 friend FXAPI FXDHVec operator*(const FXDHVec& v,const FXDHMat& m); 00074 friend FXAPI FXDHVec operator*(const FXDHMat& a,const FXDHVec& v); 00075 00076 /// Mutiply matrix and vector, for projective matrix 00077 friend FXAPI FXDVec operator*(const FXDVec& v,const FXDHMat& m); 00078 friend FXAPI FXDVec operator*(const FXDHMat& a,const FXDVec& v); 00079 00080 /// Set to identity matrix 00081 FXDHMat& eye(); 00082 00083 /// Orthographic projection 00084 FXDHMat& ortho(FXdouble left,FXdouble right,FXdouble bottom,FXdouble top,FXdouble hither,FXdouble yon); 00085 00086 /// Perspective projection 00087 FXDHMat& frustum(FXdouble left,FXdouble right,FXdouble bottom,FXdouble top,FXdouble hither,FXdouble yon); 00088 00089 /// Multiply by left-hand matrix 00090 FXDHMat& left(); 00091 00092 /// Multiply by rotation about unit-quaternion 00093 FXDHMat& rot(const FXDQuat& q); 00094 00095 /// Multiply by rotation c,s about axis 00096 FXDHMat& rot(const FXDVec& v,FXdouble c,FXdouble s); 00097 00098 /// Multiply by rotation of phi about axis 00099 FXDHMat& rot(const FXDVec& v,FXdouble phi); 00100 00101 /// Multiply by x-rotation 00102 FXDHMat& xrot(FXdouble c,FXdouble s); 00103 FXDHMat& xrot(FXdouble phi); 00104 00105 /// Multiply by y-rotation 00106 FXDHMat& yrot(FXdouble c,FXdouble s); 00107 FXDHMat& yrot(FXdouble phi); 00108 00109 /// Multiply by z-rotation 00110 FXDHMat& zrot(FXdouble c,FXdouble s); 00111 FXDHMat& zrot(FXdouble phi); 00112 00113 /// Look at 00114 FXDHMat& look(const FXDVec& eye,const FXDVec& cntr,const FXDVec& vup); 00115 00116 /// Multiply by translation 00117 FXDHMat& trans(FXdouble tx,FXdouble ty,FXdouble tz); 00118 FXDHMat& trans(const FXDVec& v); 00119 00120 /// Multiply by scaling 00121 FXDHMat& scale(FXdouble sx,FXdouble sy,FXdouble sz); 00122 FXDHMat& scale(FXdouble s); 00123 FXDHMat& scale(const FXDVec& v); 00124 00125 /// Determinant 00126 friend FXAPI FXdouble det(const FXDHMat& m); 00127 00128 /// Transpose 00129 friend FXAPI FXDHMat transpose(const FXDHMat& m); 00130 00131 /// Invert 00132 friend FXAPI FXDHMat invert(const FXDHMat& m); 00133 00134 /// Save to a stream 00135 friend FXAPI FXStream& operator<<(FXStream& store,const FXDHMat& m); 00136 00137 /// Load from a stream 00138 friend FXAPI FXStream& operator>>(FXStream& store,FXDHMat& m); 00139 }; 00140 00141 #endif