Back to index

nux  3.0.0
Public Member Functions | Static Public Member Functions | Public Attributes
nux::Matrix2x2< T > Class Template Reference

#include <Matrix2.h>

Collaboration diagram for nux::Matrix2x2< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Matrix2x2 ()
 ~Matrix2x2 ()
 Matrix2x2 (const Matrix2x2< T > &)
Matrix2x2< T > & operator= (const Matrix2x2< T > &)
bool operator== (const Matrix2x2< T > &)
Matrix2x2< T > operator* (const Matrix2x2< T > &) const
Matrix2x2< T > operator+ (const Matrix2x2< T > &) const
Matrix2x2< T > operator- (const Matrix2x2< T > &) const
Matrix2x2< T > & operator*= (const Matrix2x2< T > &) const
Matrix2x2< T > & operator+= (const Matrix2x2< T > &) const
Matrix2x2< T > & operator-= (const Matrix2x2< T > &) const
Matrix2x2< T > operator* (const T &) const
Matrix2x2< T > operator/ (const T &) const
Matrix2x2< T > & operator*= (const T &) const
Matrix2x2< T > & operator/= (const T &) const
Vec2< T > operator* (const Vec2< T > &) const
Matrix2x2< T > operator- ()
T & operator() (unsigned int i, unsigned int j)
operator() (unsigned int i, unsigned int j) const
void Zero ()
void Identity ()
Determinant () const
void Inverse ()
Matrix2x2< T > GetInverse () const

Static Public Member Functions

static Matrix2x2< T > IDENTITY ()
static Matrix2x2< T > ZERO ()

Public Attributes

m [2][2]

Detailed Description

template<typename T>
class nux::Matrix2x2< T >

Definition at line 33 of file Matrix2.h.


Constructor & Destructor Documentation

template<typename T >
nux::Matrix2x2< T >::Matrix2x2 ( )

Definition at line 86 of file Matrix2.h.

  {
    Identity();
  }
template<typename T >
nux::Matrix2x2< T >::~Matrix2x2 ( )

Definition at line 142 of file Matrix2.h.

  {

  }
template<typename T >
nux::Matrix2x2< T >::Matrix2x2 ( const Matrix2x2< T > &  M)

Definition at line 159 of file Matrix2.h.

  {
    m[0][0] = M.m[0][0];
    m[0][1] = M.m[0][1];
    m[1][0] = M.m[1][0];
    m[1][1] = M.m[1][1];
  }

Member Function Documentation

template<typename T >
T nux::Matrix2x2< T >::Determinant ( ) const

Definition at line 92 of file Matrix2.h.

  {
    T det;
    det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
    return det;
  }
template<typename T >
Matrix2x2< T > nux::Matrix2x2< T >::GetInverse ( ) const

Definition at line 123 of file Matrix2.h.

  {
    Matrix2x2<T> Temp = *this;
    Temp.Inverse();
    return Temp;
  }

Here is the call graph for this function:

template<typename T >
void nux::Matrix2x2< T >::Identity ( )

Definition at line 517 of file Matrix2.h.

  {
    m[0][0] = 1.0;
    m[0][1] = 0.0;
    m[1][0] = 0.0;
    m[1][1] = 1.0;
  }

Here is the caller graph for this function:

template<typename T >
Matrix2x2< T > nux::Matrix2x2< T >::IDENTITY ( ) [static]

Definition at line 526 of file Matrix2.h.

  {
    Matrix2x2<T> matrix;
    matrix.Identity();
    return matrix;
  }

Here is the call graph for this function:

template<typename T >
void nux::Matrix2x2< T >::Inverse ( )

Definition at line 100 of file Matrix2.h.

  {
    T det = Determinant();

    if (det == T (0) )
    {
      // Determinant is null. Matrix cannot be inverted.
#ifdef NUX_DEBUG
      NUX_HARDWARE_BREAK;
#endif
      return;
    }

    Matrix2x2<T> Temp;
    Temp.m[0][0] = m[1][1];
    Temp.m[0][1] = -m[0][1];
    Temp.m[1][0] = -m[1][0];
    Temp.m[1][1] = m[0][0];

    *this = (T (1) / det) * Temp;
  }

Here is the caller graph for this function:

template<typename T >
T & nux::Matrix2x2< T >::operator() ( unsigned int  i,
unsigned int  j 
)

Definition at line 472 of file Matrix2.h.

  {
    return m[i][j];
  }
template<typename T >
T nux::Matrix2x2< T >::operator() ( unsigned int  i,
unsigned int  j 
) const

Definition at line 478 of file Matrix2.h.

  {
    return m[i][j];
  }
template<typename T >
Matrix2x2< T > nux::Matrix2x2< T >::operator* ( const Matrix2x2< T > &  iM) const

Definition at line 214 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] * iM.m[0][0] + m[0][1] * iM.m[1][0];
    oM.m[1][0] = m[1][0] * iM.m[0][0] + m[1][1] * iM.m[1][0];

    oM.m[0][1] = m[0][0] * iM.m[0][1] + m[0][1] * iM.m[1][1];
    oM.m[1][1] = m[1][0] * iM.m[0][1] + m[1][1] * iM.m[1][1];

    return oM;
  }
template<typename T>
Matrix2x2<T> nux::Matrix2x2< T >::operator* ( const T &  ) const
template<typename T >
Vec2< T > nux::Matrix2x2< T >::operator* ( const Vec2< T > &  V) const

Definition at line 437 of file Matrix2.h.

  {
    Vec2<T> oV;

    oV.x = V.x * m[0][0] + V.y * m[0][1];
    oV.y = V.x * m[1][0] + V.y * m[1][1];

    return oV;
  }
template<typename T >
Matrix2x2< T > & nux::Matrix2x2< T >::operator*= ( const Matrix2x2< T > &  iM) const

Definition at line 287 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] * iM.m[0][0] + m[0][1] * iM.m[1][0];
    oM.m[1][0] = m[1][0] * iM.m[0][0] + m[1][1] * iM.m[1][0];

    oM.m[0][1] = m[0][0] * iM.m[0][1] + m[0][1] * iM.m[1][1];
    oM.m[1][1] = m[1][0] * iM.m[0][1] + m[1][1] * iM.m[1][1];

    *this = oM;
    return *this;
  }
template<typename T >
Matrix2x2< T > & nux::Matrix2x2< T >::operator*= ( const T &  f) const

Definition at line 363 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] * f;
    oM.m[0][1] = m[0][1] * f;
    oM.m[1][0] = m[1][0] * f;
    oM.m[1][1] = m[1][1] * f;

    *this = oM;
    return *this;
  }
template<typename T >
Matrix2x2< T > nux::Matrix2x2< T >::operator+ ( const Matrix2x2< T > &  iM) const

Definition at line 239 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] + iM.m[0][0];
    oM.m[0][1] = m[0][1] + iM.m[0][1];
    oM.m[1][0] = m[1][0] + iM.m[1][0];
    oM.m[1][1] = m[1][1] + iM.m[1][1];

    return oM;
  }
template<typename T >
Matrix2x2< T > & nux::Matrix2x2< T >::operator+= ( const Matrix2x2< T > &  iM) const

Definition at line 313 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] + iM.m[0][0];
    oM.m[0][1] = m[0][1] + iM.m[0][1];
    oM.m[1][0] = m[1][0] + iM.m[1][0];
    oM.m[1][1] = m[1][1] + iM.m[1][1];

    *this = oM;
    return *this;
  }
template<typename T >
Matrix2x2< T > nux::Matrix2x2< T >::operator- ( const Matrix2x2< T > &  iM) const

Definition at line 263 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] - iM.m[0][0];
    oM.m[0][1] = m[0][1] - iM.m[0][1];
    oM.m[1][0] = m[1][0] - iM.m[1][0];
    oM.m[1][1] = m[1][1] - iM.m[1][1];

    return oM;
  }
template<typename T >
Matrix2x2< T > nux::Matrix2x2< T >::operator- ( )

Definition at line 459 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = -m[0][0];
    oM.m[0][1] = -m[0][1];
    oM.m[1][0] = -m[1][0];
    oM.m[1][1] = -m[1][1];

    return oM;
  }
template<typename T >
Matrix2x2< T > & nux::Matrix2x2< T >::operator-= ( const Matrix2x2< T > &  iM) const

Definition at line 338 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] - iM.m[0][0];
    oM.m[0][1] = m[0][1] - iM.m[0][1];
    oM.m[1][0] = m[1][0] - iM.m[1][0];
    oM.m[1][1] = m[1][1] - iM.m[1][1];

    *this = oM;
    return *this;
  }
template<typename T >
Matrix2x2< T > nux::Matrix2x2< T >::operator/ ( const T &  f) const

Definition at line 388 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] / f;
    oM.m[0][1] = m[0][1] / f;
    oM.m[1][0] = m[1][0] / f;
    oM.m[1][1] = m[1][1] / f;

    return oM;
  }
template<typename T >
Matrix2x2< T > & nux::Matrix2x2< T >::operator/= ( const T &  f) const

Definition at line 412 of file Matrix2.h.

  {
    Matrix2x2<T> oM;

    oM.m[0][0] = m[0][0] / f;
    oM.m[0][1] = m[0][1] / f;
    oM.m[1][0] = m[1][0] / f;
    oM.m[1][1] = m[1][1] / f;

    *this = oM;
    return *this;
  }
template<typename T >
Matrix2x2< T > & nux::Matrix2x2< T >::operator= ( const Matrix2x2< T > &  M)

Definition at line 179 of file Matrix2.h.

  {
    m[0][0] = M.m[0][0];
    m[0][1] = M.m[0][1];
    m[1][0] = M.m[1][0];
    m[1][1] = M.m[1][1];

    return (*this);
  }
template<typename T >
bool nux::Matrix2x2< T >::operator== ( const Matrix2x2< T > &  M)

Definition at line 190 of file Matrix2.h.

  {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++)
      {
        if (m[i][j] != M.m[i][j])
          return false;
      }

    return true;
  }
template<typename T >
void nux::Matrix2x2< T >::Zero ( )

Definition at line 495 of file Matrix2.h.

  {
    m[0][0] = 0.0;
    m[0][1] = 0.0;
    m[1][0] = 0.0;
    m[1][1] = 0.0;

    //memset(m, 0, sizeof(m));
  }

Here is the caller graph for this function:

template<typename T >
Matrix2x2< T > nux::Matrix2x2< T >::ZERO ( ) [static]

Definition at line 534 of file Matrix2.h.

  {
    Matrix2x2<T> matrix;
    matrix.Zero();
    return matrix;
  }

Here is the call graph for this function:


Member Data Documentation

template<typename T>
T nux::Matrix2x2< T >::m[2][2]

Definition at line 70 of file Matrix2.h.


The documentation for this class was generated from the following file: