GMatrix44.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003-2004 by Raphael Langerhorst                        *
00003  *   raphael-langerhorst@gmx.at                                            *
00004  *                                                                         *
00005  *   Copyright (C) 2004 Gerald Degeneve <gerald.degeneve@gmx.at>           *
00006  *                                                                         *
00007  *   Permission is hereby granted, free of charge, to any person obtaining *
00008  *   a copy of this software and associated documentation files (the       *
00009  *   "Software"), to deal in the Software without restriction, including   *
00010  *   without limitation the rights to use, copy, modify, merge, publish,   *
00011  *   distribute, sublicense, and/or sell copies of the Software, and to    *
00012  *   permit persons to whom the Software is furnished to do so, subject to *
00013  *   the following conditions:                                             *
00014  *                                                                         *
00015  *   The above copyright notice and this permission notice shall be        *
00016  *   included in all copies or substantial portions of the Software.       *
00017  *                                                                         *
00018  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
00019  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
00020  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
00021  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
00022  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
00023  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
00024  *   OTHER DEALINGS IN THE SOFTWARE.                                       *
00025  ***************************************************************************/
00026 
00027 #ifndef GMATRIX44H
00028 #define GMATRIX44H
00029 
00030 namespace GCS
00031 
00032 {
00033 
00034 class GVector3;
00035 
00043 class GMatrix44
00044 {
00045 
00046   public:
00050     union
00051     {
00055         struct
00056         {
00057              double m11, m12, m13, m14,
00058                     m21, m22, m23, m24,
00059                     m31, m32, m33, m34,
00060                     m41, m42, m43, m44;
00061         };
00062     
00067         double m[4][4];
00068 
00073         double n[16];
00074     };
00075 
00076   public:
00077 
00081     GMatrix44();
00082 
00086     GMatrix44(double _m11, double _m12, double _m13, double _m14,
00087               double _m21, double _m22, double _m23, double _m24,
00088               double _m31, double _m32, double _m33, double _m34,
00089               double _m41, double _m42, double _m43, double _m44);
00090     
00094     GMatrix44(const GMatrix44& original);
00095     
00096     
00100     operator double* ();
00101 
00102 
00106     GMatrix44& loadIdentity();
00107      
00108 
00113     GMatrix44 multiply(double scalar) const;
00114 
00119     GMatrix44 multiply(const GMatrix44& m) const;
00120     
00121 
00126     GVector3 transform(const GVector3& v) const;
00127     
00132     GMatrix44 operator + (const GMatrix44& m) const;
00133     
00134     
00139     GMatrix44 operator - (const GMatrix44& m) const;
00140     
00141     
00146     GMatrix44 operator * (const GMatrix44& m) const;
00147 
00148     
00153     GMatrix44 operator * (const double scalar) const;
00154     
00155     
00160     inline bool operator == (const GMatrix44& m) const;
00161 
00162     
00167     inline bool operator != (const GMatrix44& m) const;
00168     
00169     
00170     //BEGIN static matrix creation methods
00171 
00172     
00176     static GMatrix44 createIdentityMatrix();
00177     
00181     static GMatrix44 createScaleMatrix(double scalar);
00182     
00186     static GMatrix44 createScaleMatrix(const GVector3& v);
00187     
00191     static GMatrix44 createTranslationMatrix(const GVector3& v);
00192     
00197     static GMatrix44 createRotationAroundX(double angle_rad);
00198     
00202     static GMatrix44 createRotationAroundY(double angle_rad);
00203     
00207     static GMatrix44 createRotationAroundZ(double angle_rad);
00208     
00213     static GMatrix44 createRotationAroundAxis(const GVector3& v, double angle_rad);
00214     
00219     static GMatrix44 createFromOpenGL(float* values);
00220     
00221     //END static matrix creation methods
00222 };  
00223   
00224 }
00225 
00226 #endif

Generated on Thu Nov 16 07:49:12 2006 for G System by  doxygen 1.4.7