MatrixP Class Template Reference
[Projective geometryMatricesFixed-size classes]

Matrix in projective geometry, fixed-size only. More...

#include <projective.h>

List of all members.

Public Member Functions

T * array ()
 Has the same meaning as in class Matrix<T, Size+1>.
const T * array () const
 Has the same meaning as in class Matrix<T, Size+1>.
void getLinearComponent (Matrix< T, Size > *res) const
void getTranslationVector (Vector< T, Size > *res) const
Matrix< T, Size > linearComponent () const
void linearMultiply (const Vector< T, Size > &vector, Vector< T, Size > *res) const
MatrixPloadIdentity ()
MatrixPloadMatrix (const Matrix< T, Size > &matrix)
MatrixPloadRotation2 (const T &angle)
MatrixPloadRotation3 (const T &angle, const Vector< T, Size > &axis)
MatrixPloadScaling (const Vector< T, Size > &coeffs)
MatrixPloadScaling (const T &coeff)
MatrixPloadTranslation (const Vector< T, Size > &v)
MatrixPloadZero ()
Matrix< T, Size+1 > & matrix ()
 Returns a reference to the matrix as a Matrix<T, Size+1>.
const Matrix< T, Size+1 > & matrix () const
 Returns a reference to the matrix as a Matrix<T, Size+1>.
 MatrixP (const Matrix< T, Size > &other)
 MatrixP (const Matrix< T, Size+1 > &other)
 MatrixP (const MatrixP &other)
 MatrixP ()
void multiply (const Vector< T, Size+1 > &vector, Vector< T, Size+1 > *res) const
void multiply (const Vector< T, Size > &vector, Vector< T, Size > *res) const
void multiply (const MatrixP &other, MatrixP *res) const
T & operator() (int row, int col)
 Has the same meaning as in class Matrix<T, Size+1>.
const T & operator() (int row, int col) const
 Has the same meaning as in class Matrix<T, Size+1>.
Vector< T, Size+1 > operator* (const Vector< T, Size+1 > &vector) const
Vector< T, Size > operator* (const Vector< T, Size > &vector) const
MatrixP operator* (const MatrixP &other) const
MatrixPoperator*= (const MatrixP &other)
MatrixPoperator= (const MatrixP &other)
T & operator[] (int i)
 Has the same meaning as in class Matrix<T, Size+1>.
const T & operator[] (int i) const
 Has the same meaning as in class Matrix<T, Size+1>.
MatrixPprerotate2 (const T &angle)
MatrixPprerotate3 (const T &angle, const Vector< T, Size > &axis)
MatrixPprescale (const Vector< T, Size > &coeffs)
MatrixPprescale (const T &coeff)
MatrixPpretranslate (const Vector< T, Size > &v)
void resetLastRow ()
void resetTranslationVector ()
MatrixProtate2 (const T &angle)
MatrixProtate3 (const T &angle, const Vector< T, Size > &axis)
MatrixPscale (const Vector< T, Size > &coeffs)
MatrixPscale (const T &coeff)
void setLinearComponent (const Matrix< T, Size > &matrix)
void setTranslationVector (const Vector< T, Size > &v)
MatrixPtranslate (const Vector< T, Size > &v)
Vector< T, Size > translationVector () const

Protected Attributes

Matrix< T, Size+1 > m_mat
 The matrix itself.


Detailed Description

template<typename T, int Size>
class Eigen::MatrixP< T, Size >

Matrix in projective geometry, fixed-size only.

It's sometimes useful to add one dimension to the space you're working in. For instance, that allows to represent translations as matrices, which is otherwise impossible.

Internally, a MatrixP<T, n> is just a Matrix<T, n+1>. The difference is that it's regarded as a homography acting on the n-dimensional projective space, instead of being regarded as a linear map acting on the n-dimensional vector space.

The correspondence between "ordinary" vectors of size n and "projective" vectors of size n+1 is as follows. Given an ordinary vector $(x_1,\ldots,x_n)$, the corresponding projective vector is $(x_1,\ldots,x_n,1)$. Conversely, given a projective vector $(x_1,\ldots,x_n,x_{n+1})$, the corresponding ordinary vector is $(\frac{x_1}{x_{n+1}},\ldots,\frac{x_n}{x_{n+1}})$. If $x_{n+1}=0$, then the projective vector doesn't correspond to any ordinary one, and is called a "direction at infinity".

The following typedefs are provided to cover the usual cases:

    typedef MatrixP<double, 2>               MatrixP2d;
    typedef MatrixP<double, 3>               MatrixP3d;
    typedef MatrixP<double, 4>               MatrixP4d;
    typedef MatrixP<float,  2>               MatrixP2f;
    typedef MatrixP<float,  3>               MatrixP3f;
    typedef MatrixP<float,  4>               MatrixP4f;
    typedef MatrixP<std::complex<double>, 2> MatrixP2cd;
    typedef MatrixP<std::complex<double>, 3> MatrixP3cd;
    typedef MatrixP<std::complex<double>, 4> MatrixP4cd;
    typedef MatrixP<std::complex<float>,  2> MatrixP2cf;
    typedef MatrixP<std::complex<float>,  3> MatrixP3cf;
    typedef MatrixP<std::complex<float>,  4> MatrixP4cf;

For example, in an OpenGL application, the Modelview and Projection matrices can be represented as objects of MatrixP3d or MatrixP3f according to whether one prefers to work over doubles or over floats.

Another example is Qt's QMatrix class: it is equivalent to Eigen's MatrixP2d.

Tthe meaning of the entries in a MatrixP is as follows:

\[\left(\begin{array}{ccc|c} & & & \\ & L & & T \\ & & & \\ \hline 0 & \cdots & 0 & 1 \end{array}\right).\]

Here,

Note that the last row is supposed to always be equal to 0,...,0,1. Don't alter it unless you know what you're doing. However keeping it is still useful for instance for OpenGL compatibility.

When multiplying another Vector<T, Size> V by such a MatrixP, the linear component is first applied, and then the result is translated by the translation vector. Thus, the result is

\[LV+T.\]


Constructor & Destructor Documentation

MatrixP (  )  [inline]

Constructs an uninitialized MatrixP.

MatrixP ( const MatrixP< T, Size > &  other  )  [inline]

Copy constructor.

MatrixP ( const Matrix< T, Size+1 > &  other  )  [inline]

Constructs a MatrixP from a Matrix<T, Size+1>. Simply copies the entries.

MatrixP ( const Matrix< T, Size > &  other  )  [inline]

Constructs a MatrixP from a Matrix<T, Size> by calling loadMatrix().


Member Function Documentation

T* array (  )  [inline]

Has the same meaning as in class Matrix<T, Size+1>.

const T* array (  )  const [inline]

Has the same meaning as in class Matrix<T, Size+1>.

void getLinearComponent ( Matrix< T, Size > *  res  )  const [inline]

Stores into *res the linear component, i.e. the (Size x Size) topleft block.

See also:
setLinearComponent(), linearComponent()

void getTranslationVector ( Vector< T, Size > *  res  )  const [inline]

Copies into *res the Size first entries of the last column of the matrix.

See also:
setTranslationVector(), translationVector(), resetTranslationVector()

Matrix<T, Size> linearComponent (  )  const [inline]

Returns the linear component, i.e. the (Size x Size) topleft block.

See also:
setLinearComponent(), getLinearComponent()

void linearMultiply ( const Vector< T, Size > &  vector,
Vector< T, Size > *  res 
) const [inline]

Applies the linear component of the homography represented by *this to vector, and stores the result in *res. This is the same thing as multiply( const Vector<T,Size> &, Vector<T, Size> *) const, except that the translation coefficients of *this are ignored. In other words the last column of *this is ignored and the computation is done as if it were 0,...0,1.

See also:
multiply(const MatrixP &, MatrixP *) const

MatrixP& loadIdentity (  )  [inline]

MatrixP< T, Size > & loadMatrix ( const Matrix< T, Size > &  matrix  )  [inline]

Loads into *this a MatrixP constructed from a Matrix<T, Size>, by calling setLinearComponent(), and then resetLastRow() and resetTranslationVector(). The last row and last column are filled with 0's, except for the bottom-right corner entry which is set to 1. The resulting MatrixP has the same action on vectors as the original Matrix had.

See also:
setLinearComponent()

MatrixP& loadRotation2 ( const T &  angle  )  [inline]

Sets *this to be the rotation matrix of given angle in radians. See Matrix::loadRotation2(). The template parameter Size must equal 2.

See also:
rotate2(), prerotate2()

MatrixP& loadRotation3 ( const T &  angle,
const Vector< T, Size > &  axis 
) [inline]

Sets *this to be the rotation matrix of given angle in radians around given axis vector. See Matrix::loadRotation3(). The template parameter Size must equal 3.

See also:
rotate3(), prerotate3()

MatrixP& loadScaling ( const Vector< T, Size > &  coeffs  )  [inline]

Sets *this to be the scaling matrix with given vector of scaling coefficients.

See also:
loadScaling(const T&), scale(const Vector<T, Size> &), prescale(const Vector<T, Size> &)

MatrixP& loadScaling ( const T &  coeff  )  [inline]

Sets *this to be the scaling matrix with given homogeneous scaling coefficient.

See also:
loadScaling(const Vector<T,Size>&), scale(const T &), prescale(const T &)

MatrixP< T, Size > & loadTranslation ( const Vector< T, Size > &  v  )  [inline]

Sets *this to be a translation matrix, with translation vector given by v.

See also:
translate(), pretranslate(), setTranslationVector()

MatrixP& loadZero (  )  [inline]

Matrix<T, Size+1>& matrix (  )  [inline]

Returns a reference to the matrix as a Matrix<T, Size+1>.

const Matrix<T, Size+1>& matrix (  )  const [inline]

Returns a reference to the matrix as a Matrix<T, Size+1>.

void multiply ( const Vector< T, Size+1 > &  vector,
Vector< T, Size+1 > *  res 
) const [inline]

Calls Matrix::multiply(). Thus, for vectors of size Size+1, the multiplication is done as if *this were an ordinary matrix. This method is faster than operator* because it doesn't perform useless copies.

void multiply ( const Vector< T, Size > &  vector,
Vector< T, Size > *  res 
) const [inline]

Applies the homography represented by *this to vector, and stores the result in *res. Thus the linear component of *this is applied to vector, and then vector is translated by the translation coefficients of *this. This method is faster than operator* because it doesn't perform useless copies.

void multiply ( const MatrixP< T, Size > &  other,
MatrixP< T, Size > *  res 
) const [inline]

Matrix-matrix product. Calls Matrix::multiply(). This stores in *res the product (*this) * other. This method is faster than operator*= and operator* because it doesn't perform useless copies.

See also:
linearMultiply()

T& operator() ( int  row,
int  col 
) [inline]

Has the same meaning as in class Matrix<T, Size+1>.

const T& operator() ( int  row,
int  col 
) const [inline]

Has the same meaning as in class Matrix<T, Size+1>.

Vector<T, Size+1> operator* ( const Vector< T, Size+1 > &  vector  )  const [inline]

Calls Matrix::operator*(). Thus, for vectors of size Size+1, the multiplication is done as if *this were an ordinary matrix.

See also:
multiply(const Vector<T, Size+1> &, Vector<T, Size+1> *) const

Vector<T, Size> operator* ( const Vector< T, Size > &  vector  )  const [inline]

Returns the product of vector by *this, as computed by multiply( const Vector<T, Size> &, Vector<T, Size> * ).

See also:
multiply(const Vector<T, Size> &, Vector<T, Size> *) const

MatrixP operator* ( const MatrixP< T, Size > &  other  )  const [inline]

Matrix-matrix product. Calls Matrix::operator*(). For better performance use multiply(const MatrixP &, MatrixP *) const instead.

See also:
multiply(const MatrixP &, MatrixP *) const

MatrixP& operator*= ( const MatrixP< T, Size > &  other  )  [inline]

Matrix-matrix product. Calls Matrix::operator*=().

MatrixP& operator= ( const MatrixP< T, Size > &  other  )  [inline]

T& operator[] ( int  i  )  [inline]

Has the same meaning as in class Matrix<T, Size+1>.

const T& operator[] ( int  i  )  const [inline]

Has the same meaning as in class Matrix<T, Size+1>.

MatrixP& prerotate2 ( const T &  angle  )  [inline]

Multiplies *this on the left by the rotation matrix of given angle in radians. See Matrix::loadRotation2(). The template parameter Size must equal 2.

See also:
rotate2(), loadRotation2()

MatrixP& prerotate3 ( const T &  angle,
const Vector< T, Size > &  axis 
) [inline]

Multiplies *this on the left by the rotation matrix of given angle in radians around given axis vector. See Matrix::loadRotation3(). The template parameter Size must equal 3.

See also:
rotate3(), loadRotation3()

MatrixP& prescale ( const Vector< T, Size > &  coeffs  )  [inline]

Multiplies *this on the left by the scaling matrix with given vector of scaling coefficients.

See also:
prescale( const T&), scale(const Vector<T, Size> &), loadScaling(const Vector<T, Size> &)

MatrixP& prescale ( const T &  coeff  )  [inline]

Multiplies *this on the left by the scaling matrix with given homogeneous scaling coefficient.

See also:
prescale(const Vector<T,Size>&), scale(const T &), loadScaling(const T &)

MatrixP< T, Size > & pretranslate ( const Vector< T, Size > &  v  )  [inline]

Multiplies *this on the left by the translation matrix with translation vector given by v.

See also:
translate(), loadTranslation(), setTranslationVector()

void resetLastRow (  )  [inline]

Sets the last row to be 0,...,0,1.

void resetTranslationVector (  )  [inline]

Sets the last column entries to 0, except for the last row which is left unmodified.

See also:
setTranslationVector(), translationVector(), getTranslationVector()

MatrixP& rotate2 ( const T &  angle  )  [inline]

Multiplies *this on the right by the rotation matrix of given angle in radians. See Matrix::loadRotation2(). The template parameter Size must equal 2.

See also:
prerotate2(), loadRotation2()

MatrixP& rotate3 ( const T &  angle,
const Vector< T, Size > &  axis 
) [inline]

Multiplies *this on the right by the rotation matrix of given angle in radians around given axis vector. See Matrix::loadRotation3(). The template parameter Size must equal 3.

See also:
prerotate3(), loadRotation3()

MatrixP& scale ( const Vector< T, Size > &  coeffs  )  [inline]

Multiplies *this on the right by the scaling matrix with given vector of scaling coefficients.

See also:
scale(const T&), prescale(const Vector<T, Size> &), loadScaling(const Vector<T, Size> &)

MatrixP& scale ( const T &  coeff  )  [inline]

Multiplies *this on the right by the scaling matrix with given homogeneous scaling coefficient.

See also:
scale(const Vector<T,Size>&), prescale(const T &), loadScaling(const T &)

void setLinearComponent ( const Matrix< T, Size > &  matrix  )  [inline]

Sets the linear component of *this, i.e. the (Size x Size) topleft block. The last row and column are unaffected

See also:
loadMatrix(), getLinearComponent(), linearComponent()

void setTranslationVector ( const Vector< T, Size > &  v  )  [inline]

Copies v into the Size first entries of the last column of the matrix.

See also:
getTranslationVector(), translationVector(), resetTranslationVector()

MatrixP< T, Size > & translate ( const Vector< T, Size > &  v  )  [inline]

Multiplies *this on the right by the translation matrix with translation vector given by v.

See also:
pretranslate(), loadTranslation(), setTranslationVector()

Vector<T, Size> translationVector (  )  const [inline]

Returns a vector whose coords are the Size first entries of the last column of the matrix.

See also:
getTranslationVector(), setTranslationVector(), resetTranslationVector()


Member Data Documentation

Matrix<T, Size+1> m_mat [protected]

The matrix itself.


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

Generated on Tue Mar 18 15:26:21 2008 for Eigen by  doxygen 1.5.5