EMAN::Matrix3 Class Reference

#include <vecmath.h>

List of all members.

Public Member Functions

 Matrix3 ()
 Matrix3 (const Vector3 &row0, const Vector3 &row1, const Vector3 &row2)
 Matrix3 (const Matrix3 &m)
Matrix3operator= (const Matrix3 &m)
int index (int row, int col) const
const double & operator() (int row, int col) const
double & operator() (int row, int col)
Vector3 row (int r) const
Vector3 column (int c) const
Matrix3 transpose () const
Matrix3 operator+ (const Matrix3 &m) const
Matrix3operator *= (double s)
Vector3 operator * (const Vector3 &v) const
Point3 operator * (const Point3 &p) const
Matrix3 operator * (const Matrix3 &m) const
double determinant () const
Matrix3 inverse () const
bool operator== (const Matrix3 &m) const
bool approxEqual (const Matrix3 &m, double eps=1e-12) const
void print () const

Static Public Member Functions

static Matrix3 identity ()
static Matrix3 rotationXYZtoUVW (Vector3 u, Vector3 v, Vector3 w)
static double det2x2 (double a, double b, double c, double d)

Private Attributes

double mat [9]


Detailed Description

Definition at line 417 of file vecmath.h.


Constructor & Destructor Documentation

EMAN::Matrix3::Matrix3 (  )  [inline]

Definition at line 419 of file vecmath.h.

References index(), and mat.

Referenced by identity(), inverse(), and rotationXYZtoUVW().

00419                       {
00420                 for ( int i = 0; i < 3; i++ )
00421                     for ( int j = 0; j < 3; j++ )
00422                         mat[ index(i,j) ] = (i == j) ? 1.0 : 0.0;
00423             }

EMAN::Matrix3::Matrix3 ( const Vector3 row0,
const Vector3 row1,
const Vector3 row2 
) [inline]

Definition at line 425 of file vecmath.h.

References index(), and mat.

00425                                                                                    {
00426                 for ( int i = 0; i < 3; i++ ) {
00427                     mat[ index( 0, i ) ] = row0[i];
00428                     mat[ index( 1, i ) ] = row1[i];
00429                     mat[ index( 2, i ) ] = row2[i];
00430                 }
00431             }

EMAN::Matrix3::Matrix3 ( const Matrix3 m  )  [inline]

Definition at line 433 of file vecmath.h.

00433                                       {
00434                 (*this) = m;
00435             }


Member Function Documentation

bool EMAN::Matrix3::approxEqual ( const Matrix3 m,
double  eps = 1e-12 
) const [inline]

Definition at line 553 of file vecmath.h.

References EMAN::isZero(), and mat.

00553                                                                            {
00554                 for ( int i = 0; i < 9; i++ )
00555                     if ( isZero( mat[i] - m.mat[i], eps ) )
00556                         return false;
00557                 return true;
00558             }

Vector3 EMAN::Matrix3::column ( int  c  )  const [inline]

Definition at line 452 of file vecmath.h.

References index(), and mat.

00452                                         {
00453                 return Vector3( mat[index(0,c)], mat[index(1,c)], mat[index(2,c)] );
00454             }

static double EMAN::Matrix3::det2x2 ( double  a,
double  b,
double  c,
double  d 
) [inline, static]

Definition at line 515 of file vecmath.h.

Referenced by inverse().

00515                                                                          {
00516                 return a * d - b * c;
00517             }

double EMAN::Matrix3::determinant (  )  const [inline]

Definition at line 519 of file vecmath.h.

Referenced by inverse().

00519                                        {
00520                 return ((*this)(0,0) * (*this)(1,1) * (*this)(2,2) +
00521                         (*this)(0,1) * (*this)(1,2) * (*this)(2,0) +
00522                         (*this)(0,2) * (*this)(1,0) * (*this)(2,1) -
00523                         (*this)(0,2) * (*this)(1,1) * (*this)(2,0) -
00524                         (*this)(0,0) * (*this)(1,2) * (*this)(2,1) -
00525                         (*this)(0,1) * (*this)(1,0) * (*this)(2,2));
00526             }

static Matrix3 EMAN::Matrix3::identity (  )  [inline, static]

Definition at line 503 of file vecmath.h.

References Matrix3().

00503                                       {
00504                 return Matrix3(Vector3(1, 0, 0),
00505                                Vector3(0, 1, 0),
00506                                Vector3(0, 0, 1));
00507             }

int EMAN::Matrix3::index ( int  row,
int  col 
) const [inline]

Definition at line 443 of file vecmath.h.

References Assert.

Referenced by column(), Matrix3(), operator()(), and row().

00443 { Assert( row >= 0 && row < 3 ); Assert( col >= 0 && col < 3 ); return col * 3 + row; }

Matrix3 EMAN::Matrix3::inverse (  )  const [inline]

Definition at line 528 of file vecmath.h.

References Assert, det2x2(), determinant(), EMAN::isZero(), and Matrix3().

00528                                     {
00529                         Matrix3 adjoint = Matrix3( Vector3(  det2x2((*this)(1,1), (*this)(1,2), (*this)(2,1), (*this)(2,2)),
00530                                           -det2x2((*this)(1,0), (*this)(1,2), (*this)(2,0), (*this)(2,2)),
00531                                            det2x2((*this)(1,0), (*this)(1,1), (*this)(2,0), (*this)(2,1)) ),
00532                                                         Vector3( -det2x2((*this)(0,1), (*this)(0,2), (*this)(2,1), (*this)(2,2)),
00533                                            det2x2((*this)(0,0), (*this)(0,2), (*this)(2,0), (*this)(2,2)),
00534                                           -det2x2((*this)(0,0), (*this)(0,1), (*this)(2,0), (*this)(2,1)) ),
00535                                                         Vector3(  det2x2((*this)(0,1), (*this)(0,2), (*this)(1,1), (*this)(1,2)),
00536                                           -det2x2((*this)(0,0), (*this)(0,2), (*this)(1,0), (*this)(1,2)),
00537                                            det2x2((*this)(0,0), (*this)(0,1), (*this)(1,0), (*this)(1,1)) ) );
00538                 const double dDet = determinant();
00539         
00540                 Assert( isZero( dDet ) == false );
00541                 adjoint *= 1.0 / dDet;
00542         
00543                 return adjoint;
00544             }

Matrix3 EMAN::Matrix3::operator * ( const Matrix3 m  )  const [inline]

Definition at line 491 of file vecmath.h.

00491                                                          {
00492                 Matrix3 matRet;
00493                 for ( int i = 0; i < 3; i++ ) {
00494                     for ( int j = 0; j < 3; j++ ) {
00495                         matRet(i,j) = 0.0;
00496                         for ( int k = 0; k < 3; k++ )
00497                             matRet(i,j) += (*this)(i,k) * m(k,j);
00498                     }
00499                 }
00500                 return matRet;
00501             }

Point3 EMAN::Matrix3::operator * ( const Point3 p  )  const [inline]

Definition at line 485 of file vecmath.h.

00485                                                     {
00486                 return Point3((*this)(0,0) * p[0] + (*this)(0,1) * p[1] + (*this)(0,2) * p[2],
00487                               (*this)(1,0) * p[0] + (*this)(1,1) * p[1] + (*this)(1,2) * p[2],
00488                               (*this)(2,0) * p[0] + (*this)(2,1) * p[1] + (*this)(2,2) * p[2]);
00489             }

Vector3 EMAN::Matrix3::operator * ( const Vector3 v  )  const [inline]

Definition at line 478 of file vecmath.h.

References v.

00478                                                       {
00479                 return Vector3((*this)(0,0) * v[0] + (*this)(0,1) * v[1] + (*this)(0,2) * v[2],
00480                                (*this)(1,0) * v[0] + (*this)(1,1) * v[1] + (*this)(1,2) * v[2],
00481                                (*this)(2,0) * v[0] + (*this)(2,1) * v[1] + (*this)(2,2) * v[2]);
00482             }

Matrix3& EMAN::Matrix3::operator *= ( double  s  )  [inline]

Definition at line 471 of file vecmath.h.

References mat.

00471                                           {
00472                 for ( int i = 0; i < 9; i++ )
00473                     mat[i] *= s;
00474                 return *this;
00475             }

double& EMAN::Matrix3::operator() ( int  row,
int  col 
) [inline]

Definition at line 446 of file vecmath.h.

References index(), and mat.

00446 { return mat[ index(row,col) ]; }

const double& EMAN::Matrix3::operator() ( int  row,
int  col 
) const [inline]

Definition at line 445 of file vecmath.h.

References index(), and mat.

00445 { return mat[ index(row,col) ]; }

Matrix3 EMAN::Matrix3::operator+ ( const Matrix3 m  )  const [inline]

Definition at line 464 of file vecmath.h.

References mat.

00464                                                        {
00465                 Matrix3 matRet;
00466                 for ( int i = 0; i < 9; i++ )
00467                     matRet.mat[i] = mat[i] + m.mat[i];
00468                 return matRet;
00469             }

Matrix3& EMAN::Matrix3::operator= ( const Matrix3 m  )  [inline]

Definition at line 437 of file vecmath.h.

References mat.

00437                                                  {
00438                 memcpy( &mat[0], &m.mat[0], sizeof(double) * 16 );
00439                 return *this;
00440             }

bool EMAN::Matrix3::operator== ( const Matrix3 m  )  const [inline]

Definition at line 546 of file vecmath.h.

References mat.

00546                                                       {
00547                 for ( int i = 0; i < 9; i++ )
00548                     if ( mat[i] != m.mat[i] )
00549                         return false;
00550                 return true;
00551             }

void EMAN::Matrix3::print (  )  const [inline]

Definition at line 560 of file vecmath.h.

00560                                {
00561                 std::cout << "( " << (*this)(0,0) << ", " << (*this)(0,1) << ", " << (*this)(0,2) << "\n";
00562                 std::cout << "  " << (*this)(1,0) << ", " << (*this)(1,1) << ", " << (*this)(1,2) << "\n";
00563                 std::cout << "  " << (*this)(2,0) << ", " << (*this)(2,1) << ", " << (*this)(2,2) << ")\n";
00564             }

static Matrix3 EMAN::Matrix3::rotationXYZtoUVW ( Vector3  u,
Vector3  v,
Vector3  w 
) [inline, static]

Definition at line 509 of file vecmath.h.

References Matrix3(), and v.

00509                                                                              {
00510                 return Matrix3(Vector3(u[0], v[0], w[0]),
00511                                Vector3(u[1], v[1], w[1]),
00512                                Vector3(u[2], v[2], w[2]));
00513             }

Vector3 EMAN::Matrix3::row ( int  r  )  const [inline]

Definition at line 448 of file vecmath.h.

References index(), and mat.

Referenced by EMAN::operator<<().

00448                                      {
00449                 return Vector3( mat[index(r,0)], mat[index(r,1)], mat[index(r,2)] );
00450             }

Matrix3 EMAN::Matrix3::transpose (  )  const [inline]

Definition at line 456 of file vecmath.h.

00456                                       {
00457                 Matrix3 matRet;
00458                 for ( int i = 0; i < 3; i++ )
00459                     for ( int j = 0; j < 3; j++ )
00460                         matRet(i,j) = (*this)(j,i);
00461                 return matRet;
00462             }


Member Data Documentation

double EMAN::Matrix3::mat[9] [private]

Definition at line 567 of file vecmath.h.

Referenced by approxEqual(), column(), Matrix3(), operator *=(), operator()(), operator+(), operator=(), operator==(), and row().


The documentation for this class was generated from the following file:
Generated on Tue Jun 11 12:45:36 2013 for EMAN2 by  doxygen 1.4.7