![]() |
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,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (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 * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXMat3f.h,v 1.27 2009/01/26 09:40:22 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXMAT3F_H 00024 #define FXMAT3F_H 00025 00026 00027 namespace FX { 00028 00029 00030 class FXQuatf; 00031 class FXMat4f; 00032 00033 00034 /// Single-precision 3x3 matrix 00035 class FXAPI FXMat3f { 00036 protected: 00037 FXVec3f m[3]; 00038 public: 00039 00040 /// Default constructor; value is not initialized 00041 FXMat3f(){} 00042 00043 /// Initialize matrix from another matrix 00044 FXMat3f(const FXMat3f& other); 00045 00046 /// Initialize from rotation and scaling part of 4x4 matrix 00047 FXMat3f(const FXMat4f& other); 00048 00049 /// Initialize matrix from scalar 00050 FXMat3f(FXfloat w); 00051 00052 /// Initialize diagonal matrix 00053 FXMat3f(FXfloat a,FXfloat b,FXfloat c); 00054 00055 /// Initialize matrix from components 00056 FXMat3f(FXfloat a00,FXfloat a01,FXfloat a02, 00057 FXfloat a10,FXfloat a11,FXfloat a12, 00058 FXfloat a20,FXfloat a21,FXfloat a22); 00059 00060 /// Initialize matrix from three vectors 00061 FXMat3f(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); 00062 00063 /// Initialize matrix from quaternion 00064 FXMat3f(const FXQuatf& quat); 00065 00066 /// Assignment 00067 FXMat3f& operator=(const FXMat3f& other); 00068 FXMat3f& operator=(const FXMat4f& other); 00069 FXMat3f& operator=(FXfloat w); 00070 00071 /// Set value from another matrix 00072 FXMat3f& set(const FXMat3f& other); 00073 00074 /// Set from rotation and scaling part of 4x4 matrix 00075 FXMat3f& set(const FXMat4f& q); 00076 00077 /// Set value from scalar 00078 FXMat3f& set(FXfloat w); 00079 00080 /// Set diagonal matrix 00081 FXMat3f& set(FXfloat a,FXfloat b,FXfloat c); 00082 00083 /// Set value from components 00084 FXMat3f& set(FXfloat a00,FXfloat a01,FXfloat a02, 00085 FXfloat a10,FXfloat a11,FXfloat a12, 00086 FXfloat a20,FXfloat a21,FXfloat a22); 00087 00088 /// Set value from three vectors 00089 FXMat3f& set(const FXVec3f& a,const FXVec3f& b,const FXVec3f& c); 00090 00091 /// Set value from quaternion 00092 FXMat3f& set(const FXQuatf& quat); 00093 00094 /// Assignment operators 00095 FXMat3f& operator+=(const FXMat3f& w); 00096 FXMat3f& operator-=(const FXMat3f& w); 00097 FXMat3f& operator*=(const FXMat3f& w); 00098 FXMat3f& operator*=(FXfloat w); 00099 FXMat3f& operator/=(FXfloat w); 00100 00101 /// Indexing 00102 FXVec3f& operator[](FXint i){return m[i];} 00103 const FXVec3f& operator[](FXint i) const {return m[i];} 00104 00105 /// Conversion 00106 operator FXfloat*(){return m[0];} 00107 operator const FXfloat*() const {return m[0];} 00108 00109 /// Unary minus 00110 FXMat3f operator-() const; 00111 00112 /// Matrix and matrix 00113 FXMat3f operator+(const FXMat3f& w) const; 00114 FXMat3f operator-(const FXMat3f& w) const; 00115 FXMat3f operator*(const FXMat3f& w) const; 00116 00117 /// Multiply matrix and vector 00118 FXVec3f operator*(const FXVec3f& v) const; 00119 FXVec2f operator*(const FXVec2f& v) const; 00120 00121 /// Equality tests 00122 FXbool operator==(const FXMat3f& a) const; 00123 FXbool operator!=(const FXMat3f& a) const; 00124 00125 friend FXAPI FXbool operator==(const FXMat3f& a,FXfloat n); 00126 friend FXAPI FXbool operator==(FXfloat n,const FXMat3f& a); 00127 00128 friend FXAPI FXbool operator!=(const FXMat3f& a,FXfloat n); 00129 friend FXAPI FXbool operator!=(FXfloat n,const FXMat3f& a); 00130 00131 /// Matrix and scalar 00132 friend FXAPI FXMat3f operator*(FXfloat x,const FXMat3f& a); 00133 friend FXAPI FXMat3f operator*(const FXMat3f& a,FXfloat x); 00134 friend FXAPI FXMat3f operator/(const FXMat3f& a,FXfloat x); 00135 friend FXAPI FXMat3f operator/(FXfloat x,const FXMat3f& a); 00136 00137 /// Set to identity matrix 00138 FXMat3f& identity(); 00139 00140 /// Return true if identity matrix 00141 FXbool isIdentity() const; 00142 00143 /// Multiply by rotation of phi 00144 FXMat3f& rot(FXfloat c,FXfloat s); 00145 FXMat3f& rot(FXfloat phi); 00146 00147 /// Multiply by translation 00148 FXMat3f& trans(FXfloat tx,FXfloat ty); 00149 00150 /// Multiply by scaling 00151 FXMat3f& scale(FXfloat sx,FXfloat sy); 00152 FXMat3f& scale(FXfloat s); 00153 00154 /// Determinant 00155 FXfloat det() const; 00156 00157 /// Transpose 00158 FXMat3f transpose() const; 00159 00160 /// Invert 00161 FXMat3f invert() const; 00162 00163 /// Save to a stream 00164 friend FXAPI FXStream& operator<<(FXStream& store,const FXMat3f& m); 00165 00166 /// Load from a stream 00167 friend FXAPI FXStream& operator>>(FXStream& store,FXMat3f& m); 00168 }; 00169 00170 extern FXAPI FXMat3f operator*(FXfloat x,const FXMat3f& a); 00171 extern FXAPI FXMat3f operator*(const FXMat3f& a,FXfloat x); 00172 00173 extern FXAPI FXMat3f operator/(const FXMat3f& a,FXfloat x); 00174 extern FXAPI FXMat3f operator/(FXfloat x,const FXMat3f& a); 00175 00176 extern FXAPI FXbool operator==(const FXMat3f& a,FXdouble n); 00177 extern FXAPI FXbool operator==(FXdouble n,const FXMat3f& a); 00178 00179 extern FXAPI FXbool operator!=(const FXMat3f& a,FXdouble n); 00180 extern FXAPI FXbool operator!=(FXdouble n,const FXMat3f& a); 00181 00182 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat3f& m); 00183 extern FXAPI FXStream& operator>>(FXStream& store,FXMat3f& m); 00184 00185 } 00186 00187 #endif
![]() |