/////////////////////////////////////////////////////////////////////////
//                                                                     //
// This file contains the declaration and implementation of a simple   //
// 3x3 matrix class.                                                   //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
#ifndef __CMATRIX3_HPP__
#define __CMATRIX3_HPP__

#include "CSquareMatrix.hpp"
#include "CVector3.hpp"


// Simple 3x3 matrix class
template <typename T>
class CMatrix3 : public CSquareMatrix<T,3>
{
public:
  CMatrix3();
  CMatrix3(const CMatrix3& m);
};




// Default constructor
template <typename T>
inline CMatrix3<T>::CMatrix3()
  : CSquareMatrix<T,3>()
{
}


// Copy constructor
template <typename T>
inline CMatrix3<T>::CMatrix3(const CMatrix3& m)
  : CSquareMatrix<T,3>(m)
{
}


// Operator to multiply a vector by a matrix.
template <typename T>
inline CVector3<T>& operator *= (CVector3<T>& v, const CMatrix3<T>& m)
{
  CVector3<T> Copy(v);
  v.x = m(0,0)*Copy.x + m(1,0)*Copy.y + m(2,0)*Copy.z ;
  v.y = m(0,1)*Copy.x + m(1,1)*Copy.y + m(2,1)*Copy.z ;
  v.z = m(0,2)*Copy.x + m(1,2)*Copy.y + m(2,2)*Copy.z ;
  return v;
}


#endif // __CMATRIX3_HPP__
