Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
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,2006 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.13 2006/01/22 17:58:05 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXMAT3F_H 00025 #define FXMAT3F_H 00026 00027 00028 namespace FX { 00029 00030 00031 class FXQuatf; 00032 00033 00034 /// Single-precision 3x3 matrix 00035 class FXAPI FXMat3f { 00036 protected: 00037 FXVec3f m[3]; 00038 public: 00039 00040 /// Default constructor 00041 FXMat3f(){} 00042 00043 /// Initialize matrix from another matrix 00044 FXMat3f(const FXMat3f& other); 00045 00046 /// Initialize matrix from scalar 00047 FXMat3f(FXfloat w); 00048 00049 /// Initialize matrix from components 00050 FXMat3f(FXfloat a00,FXfloat a01,FXfloat a02, 00051 FXfloat a10,FXfloat a11,FXfloat a12, 00052 FXfloat a20,FXfloat a21,FXfloat a22); 00053 00054 /// Initialize matrix from three vectors 00055 FXMat3f(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); 00056 00057 /// Initialize matrix from quaternion 00058 FXMat3f(const FXQuatf& quat); 00059 00060 /// Assignment 00061 FXMat3f& operator=(const FXMat3f& other); 00062 FXMat3f& operator=(FXfloat w); 00063 00064 /// Set value from another matrix 00065 FXMat3f& set(const FXMat3f& other); 00066 00067 /// Set value from scalar 00068 FXMat3f& set(FXfloat w); 00069 00070 /// Set value from components 00071 FXMat3f& set(FXfloat a00,FXfloat a01,FXfloat a02, 00072 FXfloat a10,FXfloat a11,FXfloat a12, 00073 FXfloat a20,FXfloat a21,FXfloat a22); 00074 00075 /// Set value from three vectors 00076 FXMat3f& set(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); 00077 00078 /// Set value from quaternion 00079 FXMat3f& set(const FXQuatf& quat); 00080 00081 /// Assignment operators 00082 FXMat3f& operator+=(const FXMat3f& w); 00083 FXMat3f& operator-=(const FXMat3f& w); 00084 FXMat3f& operator*=(FXfloat w); 00085 FXMat3f& operator*=(const FXMat3f& w); 00086 FXMat3f& operator/=(FXfloat w); 00087 00088 /// Indexing 00089 FXVec3f& operator[](FXint i){return m[i];} 00090 const FXVec3f& operator[](FXint i) const {return m[i];} 00091 00092 /// Conversion 00093 operator FXfloat*(){return m[0];} 00094 operator const FXfloat*() const {return m[0];} 00095 00096 /// Unary minus 00097 FXMat3f operator-() const; 00098 00099 /// Matrix and matrix 00100 FXMat3f operator+(const FXMat3f& w) const; 00101 FXMat3f operator-(const FXMat3f& w) const; 00102 FXMat3f operator*(const FXMat3f& w) const; 00103 00104 /// Multiply matrix and vector 00105 FXVec3f operator*(const FXVec3f& v) const; 00106 FXVec2f operator*(const FXVec2f& v) const; 00107 00108 /// Matrix and scalar 00109 friend FXAPI FXMat3f operator*(FXfloat x,const FXMat3f& a); 00110 friend FXAPI FXMat3f operator*(const FXMat3f& a,FXfloat x); 00111 friend FXAPI FXMat3f operator/(const FXMat3f& a,FXfloat x); 00112 friend FXAPI FXMat3f operator/(FXfloat x,const FXMat3f& a); 00113 00114 /// Set identity matrix 00115 FXMat3f& eye(); 00116 00117 /// Multiply by rotation of phi 00118 FXMat3f& rot(FXfloat c,FXfloat s); 00119 FXMat3f& rot(FXfloat phi); 00120 00121 /// Multiply by translation 00122 FXMat3f& trans(FXfloat tx,FXfloat ty); 00123 00124 /// Multiply by scaling 00125 FXMat3f& scale(FXfloat sx,FXfloat sy); 00126 FXMat3f& scale(FXfloat s); 00127 00128 /// Determinant 00129 FXfloat det() const; 00130 00131 /// Transpose 00132 FXMat3f transpose() const; 00133 00134 /// Invert 00135 FXMat3f invert() const; 00136 00137 /// Save to a stream 00138 friend FXAPI FXStream& operator<<(FXStream& store,const FXMat3f& m); 00139 00140 /// Load from a stream 00141 friend FXAPI FXStream& operator>>(FXStream& store,FXMat3f& m); 00142 }; 00143 00144 extern FXAPI FXMat3f operator*(FXfloat x,const FXMat3f& a); 00145 extern FXAPI FXMat3f operator*(const FXMat3f& a,FXfloat x); 00146 extern FXAPI FXMat3f operator/(const FXMat3f& a,FXfloat x); 00147 extern FXAPI FXMat3f operator/(FXfloat x,const FXMat3f& a); 00148 00149 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat3f& m); 00150 extern FXAPI FXStream& operator>>(FXStream& store,FXMat3f& m); 00151 00152 } 00153 00154 #endif
Copyright © 1997-2005 Jeroen van der Zijp |