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

FXMat4f.h

00001 /******************************************************************************** 00002 * * 00003 * S i n g l e - P r e c i s i o n 4 x 4 M a t r i x * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1994,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: FXMat4f.h,v 1.5 2005/01/16 16:06:06 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXMAT4F_H 00025 #define FXMAT4F_H 00026 00027 00028 namespace FX { 00029 00030 00031 /// Single-precision 4x4 matrix 00032 class FXAPI FXMat4f { 00033 protected: 00034 FXVec4f m[4]; 00035 public: 00036 /// Constructors 00037 FXMat4f(){} 00038 FXMat4f(FXfloat w); 00039 FXMat4f(FXfloat a00,FXfloat a01,FXfloat a02,FXfloat a03, 00040 FXfloat a10,FXfloat a11,FXfloat a12,FXfloat a13, 00041 FXfloat a20,FXfloat a21,FXfloat a22,FXfloat a23, 00042 FXfloat a30,FXfloat a31,FXfloat a32,FXfloat a33); 00043 FXMat4f(const FXVec4f& a,const FXVec4f& b,const FXVec4f& c,const FXVec4f& d); 00044 FXMat4f(const FXMat4f& other); 00045 00046 /// Assignment operators 00047 FXMat4f& operator=(const FXMat4f& other); 00048 FXMat4f& operator=(FXfloat w); 00049 FXMat4f& operator+=(const FXMat4f& w); 00050 FXMat4f& operator-=(const FXMat4f& w); 00051 FXMat4f& operator*=(FXfloat w); 00052 FXMat4f& operator*=(const FXMat4f& w); 00053 FXMat4f& operator/=(FXfloat w); 00054 00055 /// Indexing 00056 FXVec4f& operator[](FXint i){return m[i];} 00057 const FXVec4f& operator[](FXint i) const {return m[i];} 00058 00059 /// Conversion 00060 operator FXfloat*(){return m[0];} 00061 operator const FXfloat*() const {return m[0];} 00062 00063 /// Other operators 00064 friend FXAPI FXMat4f operator+(const FXMat4f& a,const FXMat4f& b); 00065 friend FXAPI FXMat4f operator-(const FXMat4f& a,const FXMat4f& b); 00066 friend FXAPI FXMat4f operator-(const FXMat4f& a); 00067 friend FXAPI FXMat4f operator*(const FXMat4f& a,const FXMat4f& b); 00068 friend FXAPI FXMat4f operator*(FXfloat x,const FXMat4f& a); 00069 friend FXAPI FXMat4f operator*(const FXMat4f& a,FXfloat x); 00070 friend FXAPI FXMat4f operator/(const FXMat4f& a,FXfloat x); 00071 friend FXAPI FXMat4f operator/(FXfloat x,const FXMat4f& a); 00072 00073 /// Multiply matrix and vector 00074 friend FXAPI FXVec4f operator*(const FXVec4f& v,const FXMat4f& m); 00075 friend FXAPI FXVec4f operator*(const FXMat4f& a,const FXVec4f& v); 00076 00077 /// Mutiply matrix and vector, for non-projective matrix 00078 friend FXAPI FXVec3f operator*(const FXVec3f& v,const FXMat4f& m); 00079 friend FXAPI FXVec3f operator*(const FXMat4f& a,const FXVec3f& v); 00080 00081 /// Set identity matrix 00082 FXMat4f& eye(); 00083 00084 /// Orthographic projection 00085 FXMat4f& ortho(FXfloat left,FXfloat right,FXfloat bottom,FXfloat top,FXfloat hither,FXfloat yon); 00086 00087 /// Perspective projection 00088 FXMat4f& frustum(FXfloat left,FXfloat right,FXfloat bottom,FXfloat top,FXfloat hither,FXfloat yon); 00089 00090 /// Multiply by left-hand matrix 00091 FXMat4f& left(); 00092 00093 /// Multiply by rotation about unit-quaternion 00094 FXMat4f& rot(const FXQuatf& q); 00095 00096 /// Multiply by rotation c,s about axis 00097 FXMat4f& rot(const FXVec3f& v,FXfloat c,FXfloat s); 00098 00099 /// Multiply by rotation of phi about axis 00100 FXMat4f& rot(const FXVec3f& v,FXfloat phi); 00101 00102 /// Multiply by x-rotation 00103 FXMat4f& xrot(FXfloat c,FXfloat s); 00104 FXMat4f& xrot(FXfloat phi); 00105 00106 /// Multiply by y-rotation 00107 FXMat4f& yrot(FXfloat c,FXfloat s); 00108 FXMat4f& yrot(FXfloat phi); 00109 00110 /// Multiply by z-rotation 00111 FXMat4f& zrot(FXfloat c,FXfloat s); 00112 FXMat4f& zrot(FXfloat phi); 00113 00114 /// Look at 00115 FXMat4f& look(const FXVec3f& eye,const FXVec3f& cntr,const FXVec3f& vup); 00116 00117 /// Multiply by translation 00118 FXMat4f& trans(FXfloat tx,FXfloat ty,FXfloat tz); 00119 FXMat4f& trans(const FXVec3f& v); 00120 00121 /// Multiply by scaling 00122 FXMat4f& scale(FXfloat sx,FXfloat sy,FXfloat sz); 00123 FXMat4f& scale(FXfloat s); 00124 FXMat4f& scale(const FXVec3f& v); 00125 00126 /// Determinant 00127 friend FXAPI FXfloat det(const FXMat4f& m); 00128 00129 /// Transpose 00130 friend FXAPI FXMat4f transpose(const FXMat4f& m); 00131 00132 /// Invert 00133 friend FXAPI FXMat4f invert(const FXMat4f& m); 00134 00135 /// Save to a stream 00136 friend FXAPI FXStream& operator<<(FXStream& store,const FXMat4f& m); 00137 00138 /// Load from a stream 00139 friend FXAPI FXStream& operator>>(FXStream& store,FXMat4f& m); 00140 }; 00141 00142 } 00143 00144 #endif

Copyright © 1997-2005 Jeroen van der Zijp