- Cal3D 0.11 API Reference -

matrix.h

00001 //****************************************************************************//
00002 // matrix.h                                                                   //
00003 // Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger                       //
00004 //****************************************************************************//
00005 // This library is free software; you can redistribute it and/or modify it    //
00006 // under the terms of the GNU Lesser General Public License as published by   //
00007 // the Free Software Foundation; either version 2.1 of the License, or (at    //
00008 // your option) any later version.                                            //
00009 //****************************************************************************//
00010 
00011 #ifndef CAL_MATRIX_H
00012 #define CAL_MATRIX_H
00013 
00014 //****************************************************************************//
00015 // Includes                                                                   //
00016 //****************************************************************************//
00017 
00018 #include "cal3d/global.h"
00019 
00020 //****************************************************************************//
00021 // Forward declarations                                                       //
00022 //****************************************************************************//
00023 
00024 class CalQuaternion;
00025 
00026 //****************************************************************************//
00027 // Class declaration                                                          //
00028 //****************************************************************************//
00029 
00030 /*****************************************************************************/
00034 class CAL3D_API CalMatrix
00035 {
00036     // member variables
00037 public:
00038     float dxdx,dydx,dzdx;
00039     float dxdy,dydy,dzdy;
00040     float dxdz,dydz,dzdz;
00041     
00042     // constructors/destructor
00043 public:
00044     inline CalMatrix()  : dxdx(0.0), dydx(0.0), dzdx(0.0),
00045         dxdy(0.0), dydy(0.0), dzdy(0.0),
00046         dxdz(0.0), dydz(0.0), dzdz(0.0)
00047     {
00048     }
00049     
00050     CalMatrix(const CalQuaternion &q);
00051     
00052     inline CalMatrix(float weight, const CalMatrix &m)
00053     {
00054         dxdx = m.dxdx*weight;
00055         dxdy = m.dxdy*weight;
00056         dxdz = m.dxdz*weight;
00057         dydx = m.dydx*weight;
00058         dydy = m.dydy*weight;
00059         dydz = m.dydz*weight;
00060         dzdx = m.dzdx*weight;
00061         dzdy = m.dzdy*weight;
00062         dzdz = m.dzdz*weight;
00063     }
00064     
00065     
00066     inline ~CalMatrix() {};
00067     
00068     // member functions
00069 public:
00070     void operator=(const CalQuaternion& q);
00071     
00072     inline void operator=(const CalMatrix& m)
00073     {
00074         dxdx=m.dxdx; dxdy=m.dxdy; dxdz=m.dxdz;
00075         dydx=m.dydx; dydy=m.dydy; dydz=m.dydz;
00076         dzdx=m.dzdx; dzdy=m.dzdy; dzdz=m.dzdz;
00077     }
00078     inline void operator *= (const CalMatrix &m)
00079     {
00080         float ndxdx=m.dxdx*dxdx+m.dxdy*dydx+m.dxdz*dzdx;
00081         float ndydx=m.dydx*dxdx+m.dydy*dydx+m.dydz*dzdx;
00082         float ndzdx=m.dzdx*dxdx+m.dzdy*dydx+m.dzdz*dzdx;
00083         
00084         float ndxdy=m.dxdx*dxdy+m.dxdy*dydy+m.dxdz*dzdy;
00085         float ndydy=m.dydx*dxdy+m.dydy*dydy+m.dydz*dzdy;
00086         float ndzdy=m.dzdx*dxdy+m.dzdy*dydy+m.dzdz*dzdy;
00087         
00088         float ndxdz=m.dxdx*dxdz+m.dxdy*dydz+m.dxdz*dzdz;
00089         float ndydz=m.dydx*dxdz+m.dydy*dydz+m.dydz*dzdz;
00090         float ndzdz=m.dzdx*dxdz+m.dzdy*dydz+m.dzdz*dzdz;
00091         
00092         dxdx=ndxdx;
00093         dydx=ndydx;
00094         dzdx=ndzdx;
00095         dxdy=ndxdy;
00096         dydy=ndydy;
00097         dzdy=ndzdy;
00098         dxdz=ndxdz;
00099         dydz=ndydz;
00100         dzdz=ndzdz;
00101     }
00102     
00103     inline void operator *= (float factor)
00104     {
00105         dxdx *= factor;
00106         dydx *= factor;
00107         dzdx *= factor;
00108         dxdy *= factor;
00109         dydy *= factor;
00110         dzdy *= factor;
00111         dxdz *= factor;
00112         dydz *= factor;
00113         dzdz *= factor;
00114     }
00115     inline void blend(float factor, const CalMatrix& m)
00116     {
00117         dxdx += m.dxdx*factor;
00118         dydx += m.dydx*factor;
00119         dzdx += m.dzdx*factor;
00120         dxdy += m.dxdy*factor;
00121         dydy += m.dydy*factor;
00122         dzdy += m.dzdy*factor;
00123         dxdz += m.dxdz*factor;
00124         dydz += m.dydz*factor;
00125         dzdz += m.dzdz*factor;
00126     }
00127     
00128     inline float det()
00129     {
00130         return dxdx * (dydy*dzdz-dydz*dzdy)
00131             -dxdy* ( dydx*dzdz-dzdx*dydz)
00132             +dxdz* (dydx*dzdy-dzdx*dydy);
00133     }
00134     
00135 };
00136 
00137 
00138 #endif
00139 
00140 //****************************************************************************//

Generated at Thu Jun 29 19:03:59 2006 by The Cal3D Team with Doxygen 1.4.6