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

FXMat3f.h

00001 /******************************************************************************** 00002 * * 00003 * S i n g 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,2004 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: FXMat3f.h,v 1.5 2004/02/08 17:17:33 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXMAT3F_H 00025 #define FXMAT3F_H 00026 00027 00028 namespace FX { 00029 00030 00031 /// Single-precision 3x3 matrix 00032 class FXAPI FXMat3f { 00033 protected: 00034 FXVec3f m[3]; 00035 public: 00036 /// Constructors 00037 FXMat3f(){} 00038 FXMat3f(FXfloat w); 00039 FXMat3f(FXfloat a00,FXfloat a01,FXfloat a02, 00040 FXfloat a10,FXfloat a11,FXfloat a12, 00041 FXfloat a20,FXfloat a21,FXfloat a22); 00042 FXMat3f(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); 00043 FXMat3f(const FXMat3f& other); 00044 00045 /// Assignment operators 00046 FXMat3f& operator=(const FXMat3f& other); 00047 FXMat3f& operator=(FXfloat w); 00048 FXMat3f& operator+=(const FXMat3f& w); 00049 FXMat3f& operator-=(const FXMat3f& w); 00050 FXMat3f& operator*=(FXfloat w); 00051 FXMat3f& operator*=(const FXMat3f& w); 00052 FXMat3f& operator/=(FXfloat w); 00053 00054 /// Indexing 00055 FXVec3f& operator[](FXint i){return m[i];} 00056 const FXVec3f& operator[](FXint i) const {return m[i];} 00057 00058 /// Conversion 00059 operator FXfloat*(){return m[0];} 00060 operator const FXfloat*() const {return m[0];} 00061 00062 /// Other operators 00063 friend FXAPI FXMat3f operator+(const FXMat3f& a,const FXMat3f& b); 00064 friend FXAPI FXMat3f operator-(const FXMat3f& a,const FXMat3f& b); 00065 friend FXAPI FXMat3f operator-(const FXMat3f& a); 00066 friend FXAPI FXMat3f operator*(const FXMat3f& a,const FXMat3f& b); 00067 friend FXAPI FXMat3f operator*(FXfloat x,const FXMat3f& a); 00068 friend FXAPI FXMat3f operator*(const FXMat3f& a,FXfloat x); 00069 friend FXAPI FXMat3f operator/(const FXMat3f& a,FXfloat x); 00070 friend FXAPI FXMat3f operator/(FXfloat x,const FXMat3f& a); 00071 00072 /// Multiply matrix and vector 00073 friend FXAPI FXVec3f operator*(const FXVec3f& v,const FXMat3f& m); 00074 friend FXAPI FXVec3f operator*(const FXMat3f& a,const FXVec3f& v); 00075 00076 /// Mutiply matrix and vector, for non-projective matrix 00077 friend FXAPI FXVec2f operator*(const FXVec2f& v,const FXMat3f& m); 00078 friend FXAPI FXVec2f operator*(const FXMat3f& a,const FXVec2f& v); 00079 00080 /// Set identity matrix 00081 FXMat3f& eye(); 00082 00083 /// Multiply by rotation of phi 00084 FXMat3f& rot(FXfloat c,FXfloat s); 00085 FXMat3f& rot(FXfloat phi); 00086 00087 /// Multiply by translation 00088 FXMat3f& trans(FXfloat tx,FXfloat ty); 00089 00090 /// Multiply by scaling 00091 FXMat3f& scale(FXfloat sx,FXfloat sy); 00092 FXMat3f& scale(FXfloat s); 00093 00094 /// Determinant 00095 friend FXAPI FXfloat det(const FXMat3f& m); 00096 00097 /// Transpose 00098 friend FXAPI FXMat3f transpose(const FXMat3f& m); 00099 00100 /// Invert 00101 friend FXAPI FXMat3f invert(const FXMat3f& m); 00102 00103 /// Save to a stream 00104 friend FXAPI FXStream& operator<<(FXStream& store,const FXMat3f& m); 00105 00106 /// Load from a stream 00107 friend FXAPI FXStream& operator>>(FXStream& store,FXMat3f& m); 00108 }; 00109 00110 } 00111 00112 #endif

Copyright © 1997-2004 Jeroen van der Zijp