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

FXMat3d.h

00001 /******************************************************************************** 00002 * * 00003 * D o u b l e - P r e c i s i o n 3 x 3 M a t r i x * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003,2005 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: FXMat3d.h,v 1.5 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXMAT3D_H 00025 #define FXMAT3D_H 00026 00027 00028 namespace FX { 00029 00030 00031 class FXQuatd; 00032 00033 00034 /// Double-precision 3x3 matrix 00035 class FXAPI FXMat3d { 00036 protected: 00037 FXVec3d m[3]; 00038 public: 00039 00040 /// Default constructor 00041 FXMat3d(){} 00042 00043 /// Copy constructor 00044 FXMat3d(const FXMat3d& other); 00045 00046 /// Construct from scalar number 00047 FXMat3d(FXdouble w); 00048 00049 /// Construct from components 00050 FXMat3d(FXdouble a00,FXdouble a01,FXdouble a02, 00051 FXdouble a10,FXdouble a11,FXdouble a12, 00052 FXdouble a20,FXdouble a21,FXdouble a22); 00053 00054 /// Construct matrix from three vectors 00055 FXMat3d(const FXVec3d& a,const FXVec3d& b,const FXVec3d& c); 00056 00057 /// Construct rotation matrix from quaternion 00058 FXMat3d(const FXQuatd& quat); 00059 00060 /// Assignment operators 00061 FXMat3d& operator=(const FXMat3d& other); 00062 FXMat3d& operator=(FXdouble w); 00063 FXMat3d& operator+=(const FXMat3d& w); 00064 FXMat3d& operator-=(const FXMat3d& w); 00065 FXMat3d& operator*=(FXdouble w); 00066 FXMat3d& operator*=(const FXMat3d& w); 00067 FXMat3d& operator/=(FXdouble w); 00068 00069 /// Indexing 00070 FXVec3d& operator[](FXint i){return m[i];} 00071 const FXVec3d& operator[](FXint i) const {return m[i];} 00072 00073 /// Conversion 00074 operator FXdouble*(){return m[0];} 00075 operator const FXdouble*() const {return m[0];} 00076 00077 /// Other operators 00078 friend FXAPI FXMat3d operator+(const FXMat3d& a,const FXMat3d& b); 00079 friend FXAPI FXMat3d operator-(const FXMat3d& a,const FXMat3d& b); 00080 friend FXAPI FXMat3d operator-(const FXMat3d& a); 00081 friend FXAPI FXMat3d operator*(const FXMat3d& a,const FXMat3d& b); 00082 friend FXAPI FXMat3d operator*(FXdouble x,const FXMat3d& a); 00083 friend FXAPI FXMat3d operator*(const FXMat3d& a,FXdouble x); 00084 friend FXAPI FXMat3d operator/(const FXMat3d& a,FXdouble x); 00085 friend FXAPI FXMat3d operator/(FXdouble x,const FXMat3d& a); 00086 00087 /// Multiply matrix and vector 00088 friend FXAPI FXVec3d operator*(const FXVec3d& v,const FXMat3d& m); 00089 friend FXAPI FXVec3d operator*(const FXMat3d& a,const FXVec3d& v); 00090 00091 /// Mutiply matrix and vector, for non-projective matrix 00092 friend FXAPI FXVec2d operator*(const FXVec2d& v,const FXMat3d& m); 00093 friend FXAPI FXVec2d operator*(const FXMat3d& a,const FXVec2d& v); 00094 00095 /// Set identity matrix 00096 FXMat3d& eye(); 00097 00098 /// Multiply by rotation of phi 00099 FXMat3d& rot(FXdouble c,FXdouble s); 00100 FXMat3d& rot(FXdouble phi); 00101 00102 /// Multiply by translation 00103 FXMat3d& trans(FXdouble tx,FXdouble ty); 00104 00105 /// Multiply by scaling 00106 FXMat3d& scale(FXdouble sx,FXdouble sy); 00107 FXMat3d& scale(FXdouble s); 00108 00109 /// Determinant 00110 friend FXAPI FXdouble det(const FXMat3d& m); 00111 00112 /// Transpose 00113 friend FXAPI FXMat3d transpose(const FXMat3d& m); 00114 00115 /// Invert 00116 friend FXAPI FXMat3d invert(const FXMat3d& m); 00117 00118 /// Save to a stream 00119 friend FXAPI FXStream& operator<<(FXStream& store,const FXMat3d& m); 00120 00121 /// Load from a stream 00122 friend FXAPI FXStream& operator>>(FXStream& store,FXMat3d& m); 00123 }; 00124 00125 } 00126 00127 #endif

Copyright © 1997-2005 Jeroen van der Zijp