mat Class Reference

double-precision 3x3 matrix class More...

#include <mat.hpp>

List of all members.

Public Member Functions

 mat ()
 mat (const mat &)
 mat (const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &, const double &)
 ~mat ()
double & operator() (const int &, const int &)
double operator() (const int &, const int &) const
mat operator+ (void)
mat operator- (void)
matoperator= (const mat &)
matoperator+= (const mat &)
matoperator-= (const mat &)
matoperator *= (const mat &)
matoperator *= (const double &)
matoperator/= (const double &)

Public Attributes

double xx
 $ M_{00} $ component
double xy
 $ M_{01} $ component
double xz
 $ M_{02} $ component
double yx
 $ M_{10} $ component
double yy
 $ M_{11} $ component
double yz
 $ M_{12} $ component
double zx
 $ M_{20} $ component
double zy
 $ M_{21} $ component
double zz
 $ M_{22} $ component

Friends

std::ostream & operator<< (std::ostream &, const mat &)
double det (const mat &)
mat inv (const mat &)
mat trans (const mat &)
void swap (mat &, mat &)
mat operator+ (const mat &, const mat &)
mat operator- (const mat &, const mat &)
mat operator * (const mat &, const mat &)
vec operator * (const mat &, const vec &)
mat operator * (const mat &, const double &)
mat operator/ (const mat &, const double &)
mat operator * (const double &, const mat &)


Detailed Description

double-precision 3x3 matrix class

Definition at line 3 of file mat.hpp.


Constructor & Destructor Documentation

mat::mat  )  [inline]
 

mat constructor without arguments

Definition at line 3 of file mat-constructor.hpp.

Referenced by operator-().

00004 {
00005   ;
00006 }

mat::mat const mat m  )  [inline]
 

mat copy constructor

Definition at line 14 of file mat-constructor.hpp.

00015   : xx(m.xx), xy(m.xy), xz(m.xz),
00016     yx(m.yx), yy(m.yy), yz(m.yz),
00017     zx(m.zx), zy(m.zy), zz(m.zz)
00018 {
00019   ;
00020 }

mat::mat const double &  _xx,
const double &  _xy,
const double &  _xz,
const double &  _yx,
const double &  _yy,
const double &  _yz,
const double &  _zx,
const double &  _zy,
const double &  _zz
[inline]
 

mat constructor to build from three components

Definition at line 28 of file mat-constructor.hpp.

00031   : xx(_xx), xy(_xy), xz(_xz),
00032     yx(_yx), yy(_yy), yz(_yz),
00033     zx(_zx), zy(_zy), zz(_zz)
00034 {
00035   ;
00036 }

mat::~mat  )  [inline]
 

mat destructor

Definition at line 44 of file mat-constructor.hpp.

00045 {
00046   ;
00047 }


Member Function Documentation

double & mat::operator() const int &  i,
const int &  j
[inline]
 

operator() for non-const object

Definition at line 3 of file mat-io.hpp.

References xx, xy, xz, yx, yy, yz, zx, zy, and zz.

00004 {
00005   switch( i ){
00006   case 0:
00007     switch( j ){
00008     case 0: return xx;
00009     case 1: return xy;
00010     case 2: return xz;
00011     }
00012   case 1:
00013     switch( j ){
00014     case 0: return yx;
00015     case 1: return yy;
00016     case 2: return yz;
00017     }
00018   case 2:
00019     switch( j ){
00020     case 0: return zx;
00021     case 1: return zy;
00022     case 2: return zz;
00023     }
00024   }
00025   std::cerr << "[ERROR] mat::operator()(const int&,const int&)" << std::endl
00026             << "The required component was not 0, 1, or 2." << std::endl
00027             << "Your input was (" << i << "," << j << ")." << std::endl;
00028   std::exit(1);
00029 }

double mat::operator() const int &  i,
const int &  j
const [inline]
 

operator() for const object

Definition at line 33 of file mat-io.hpp.

References xx, xy, xz, yx, yy, yz, zx, zy, and zz.

00034 {
00035   switch( i ){
00036   case 0:
00037     switch( j ){
00038     case 0: return xx;
00039     case 1: return xy;
00040     case 2: return xz;
00041     }
00042   case 1:
00043     switch( j ){
00044     case 0: return yx;
00045     case 1: return yy;
00046     case 2: return yz;
00047     }
00048   case 2:
00049     switch( j ){
00050     case 0: return zx;
00051     case 1: return zy;
00052     case 2: return zz;
00053     }
00054   }
00055   std::cerr << "[ERROR] mat::operator()(const int&,const int&) const"
00056             << std::endl
00057             << "The required component was not 0, 1, or 2." << std::endl
00058             << "Your input was (" << i << "," << j << ")." << std::endl;
00059   std::exit(1);
00060 }

mat mat::operator+ void   )  [inline]
 

Definition at line 2 of file mat-unary.hpp.

00003 {
00004   return( *this );
00005 }

mat mat::operator- void   )  [inline]
 

Definition at line 8 of file mat-unary.hpp.

References mat(), xx, xy, xz, yx, yy, yz, zx, zy, and zz.

00009 {
00010   return mat( -xx, -xy, -xz,
00011               -yx, -yy, -yz,
00012               -zx, -zy, -zz );
00013 }

mat & mat::operator= const mat m  )  [inline]
 

mat=mat operator

Definition at line 3 of file mat-mat.hpp.

References xx, xy, xz, yx, yy, yz, zx, zy, and zz.

00004 {
00005   xx=m.xx; xy=m.xy; xz=m.xz;
00006   yx=m.yx; yy=m.yy; yz=m.yz;
00007   zx=m.zx; zy=m.zy; zz=m.zz;
00008   return *this;
00009 }

mat & mat::operator+= const mat m  )  [inline]
 

mat+=mat operator

Definition at line 17 of file mat-mat.hpp.

References xx, xy, xz, yx, yy, yz, zx, zy, and zz.

00018 {
00019   xx+=m.xx; xy+=m.xy; xz+=m.xz;
00020   yx+=m.yx; yy+=m.yy; yz+=m.yz;
00021   zx+=m.zx; zy+=m.zy; zz+=m.zz;
00022   return *this;
00023 }

mat & mat::operator-= const mat m  )  [inline]
 

mat-=mat operator

Definition at line 27 of file mat-mat.hpp.

References xx, xy, xz, yx, yy, yz, zx, zy, and zz.

00028 {
00029   xx-=m.xx; xy-=m.xy; xz-=m.xz;
00030   yx-=m.yx; yy-=m.yy; yz-=m.yz;
00031   zx-=m.zx; zy-=m.zy; zz-=m.zz;
00032   return *this;
00033 }

mat & mat::operator *= const mat m  )  [inline]
 

mat*=mat operator

Definition at line 37 of file mat-mat.hpp.

00038 {
00039   (*this) =(*this)*m;
00040   return *this;
00041 }

mat & mat::operator *= const double &  d  )  [inline]
 

mat*=double operator

Definition at line 3 of file mat-double.hpp.

References xx, xy, xz, yx, yy, yz, zx, zy, and zz.

00004 {
00005   xx*=d; xy*=d; xz*=d;
00006   yx*=d; yy*=d; yz*=d;
00007   zx*=d; zy*=d; zz*=d;
00008   return *this;
00009 }

mat & mat::operator/= const double &  d  )  [inline]
 

mat/=double operator

Definition at line 13 of file mat-double.hpp.

References xx, xy, xz, yx, yy, yz, zx, zy, and zz.

00014 {
00015   xx/=d; xy/=d; xz/=d;
00016   yx/=d; yy/=d; yz/=d;
00017   zx/=d; zy/=d; zz/=d;
00018   return *this;
00019 }


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  s,
const mat m
[friend]
 

Definition at line 67 of file mat-io.hpp.

00068 {
00069   s << "[ " << m.xx << ", " << m.xy << ", " << m.xz
00070     << "; " << m.yx << ", " << m.yy << ", " << m.yz
00071     << "; " << m.zx << ", " << m.zy << ", " << m.zz
00072     << " ]";
00073   return s;
00074 }

double det const mat m  )  [friend]
 

return its determinant

Definition at line 3 of file mat-calc.hpp.

00004 {
00005   return
00006     m.xx*m.yy*m.zz + m.xy*m.yz*m.zx + m.xz*m.yx*m.zy
00007     -m.xx*m.yz*m.zy -m.xy*m.yx*m.zz -m.xz*m.yy*m.zx;
00008 }

mat inv const mat m  )  [friend]
 

return its inverse matrix

Definition at line 12 of file mat-calc.hpp.

00013 {
00014   double d( det(m) );
00015   return mat
00016     (
00017      (m.yy*m.zz-m.yz*m.zy)/d, (m.xz*m.zy-m.xy*m.zz)/d, (m.xy*m.yz-m.xz*m.yy)/d,
00018      (m.yz*m.zx-m.yx*m.zz)/d, (m.xx*m.zz-m.xz*m.zx)/d, (m.xz*m.yx-m.xx*m.yz)/d,
00019      (m.yx*m.zy-m.yy*m.zx)/d, (m.xy*m.zx-m.xx*m.zy)/d, (m.xx*m.yy-m.xy*m.yx)/d
00020      );
00021 }

mat trans const mat m  )  [friend]
 

return its transposed matrix

Definition at line 3 of file mat-misc.hpp.

00004 {
00005   return mat( m.xx, m.yx, m.zx,
00006               m.xy, m.yy, m.zy,
00007               m.xz, m.yz, m.zz );
00008 }

void swap mat v1,
mat v2
[friend]
 

swap two mats

Definition at line 12 of file mat-misc.hpp.

00013 {
00014   mat _v1(v1);
00015   v1 = v2;
00016   v2 =_v1;
00017 }

mat operator+ const mat m1,
const mat m2
[friend]
 

mat+mat operator

Definition at line 49 of file mat-mat.hpp.

00050 {
00051   return mat( m1.xx+m2.xx, m1.xy+m2.xy, m1.xz+m2.xz,
00052               m1.yx+m2.yx, m1.yy+m2.yy, m1.yz+m2.yz,
00053               m1.zx+m2.zx, m1.zy+m2.zy, m1.zz+m2.zz );
00054 }

mat operator- const mat m1,
const mat m2
[friend]
 

mat-mat operator

Definition at line 58 of file mat-mat.hpp.

00059 {
00060   return mat( m1.xx-m2.xx, m1.xy-m2.xy, m1.xz-m2.xz,
00061               m1.yx-m2.yx, m1.yy-m2.yy, m1.yz-m2.yz,
00062               m1.zx-m2.zx, m1.zy-m2.zy, m1.zz-m2.zz );
00063 }

mat operator * const mat m1,
const mat m2
[friend]
 

mat*mat operator

Definition at line 67 of file mat-mat.hpp.

00068 {
00069   return mat( m1.xx*m2.xx +m1.xy*m2.yx +m1.xz*m2.zx,
00070               m1.xx*m2.xy +m1.xy*m2.yy +m1.xz*m2.zy,
00071               m1.xx*m2.xz +m1.xy*m2.yz +m1.xz*m2.zz,
00072               m1.yx*m2.xx +m1.yy*m2.yx +m1.yz*m2.zx,
00073               m1.yx*m2.xy +m1.yy*m2.yy +m1.yz*m2.zy,
00074               m1.yx*m2.xz +m1.yy*m2.yz +m1.yz*m2.zz,
00075               m1.zx*m2.xx +m1.zy*m2.yx +m1.zz*m2.zx,
00076               m1.zx*m2.xy +m1.zy*m2.yy +m1.zz*m2.zy,
00077               m1.zx*m2.xz +m1.zy*m2.yz +m1.zz*m2.zz );
00078 }

vec operator * const mat m,
const vec v
[friend]
 

mat*vec operator

Definition at line 3 of file mat-vec.hpp.

00004 {
00005   return vec( m.xx*v.x +m.xy*v.y +m.xz*v.z,
00006               m.yx*v.x +m.yy*v.y +m.yz*v.z,
00007               m.zx*v.x +m.zy*v.y +m.zz*v.z );
00008 }

mat operator * const mat m,
const double &  d
[friend]
 

mat*double operator

Definition at line 27 of file mat-double.hpp.

00028 {
00029   return mat( m.xx*d, m.xy*d, m.xz*d,
00030               m.yx*d, m.yy*d, m.yz*d,
00031               m.zx*d, m.zy*d, m.zz*d );
00032 }

mat operator/ const mat m,
const double &  d
[friend]
 

mat/double operator

Definition at line 36 of file mat-double.hpp.

00037 {
00038   return mat( m.xx/d, m.xy/d, m.xz/d,
00039               m.yx/d, m.yy/d, m.yz/d,
00040               m.zx/d, m.zy/d, m.zz/d );
00041 }

mat operator * const double &  d,
const mat m
[friend]
 

double*mat operator

Definition at line 3 of file double-mat.hpp.

00004 {
00005   return mat( d*m.xx, d*m.xy, d*m.xz,
00006               d*m.yx, d*m.yy, d*m.yz,
00007               d*m.zx, d*m.zy, d*m.zz );
00008 }


Member Data Documentation

double mat::xx
 

$ M_{00} $ component

Definition at line 7 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().

double mat::xy
 

$ M_{01} $ component

Definition at line 8 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().

double mat::xz
 

$ M_{02} $ component

Definition at line 9 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().

double mat::yx
 

$ M_{10} $ component

Definition at line 10 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().

double mat::yy
 

$ M_{11} $ component

Definition at line 11 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().

double mat::yz
 

$ M_{12} $ component

Definition at line 12 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().

double mat::zx
 

$ M_{20} $ component

Definition at line 13 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().

double mat::zy
 

$ M_{21} $ component

Definition at line 14 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().

double mat::zz
 

$ M_{22} $ component

Definition at line 15 of file mat.hpp.

Referenced by operator *=(), operator()(), operator+=(), operator-(), operator-=(), operator/=(), and operator=().


The documentation for this class was generated from the following files:
Generated on Tue Mar 15 16:02:38 2005 for QVM by  doxygen 1.4.1