# Visualization Library A lightweight C++ OpenGL middleware for 2D/3D graphics | [Home] [Tutorials] [All Classes] [Grouped Classes]

# vl::Matrix4< scalar_type > Class Template Reference

The Matrix4 class is a template class that implements a generic 4x4 matrix, see also vl::dmat4, vl::fmat4, vl::umat4, vl::imat4. More...

`#include <Matrix4.hpp>`

List of all members.

## Public Member Functions
template<typename T >
| Matrix4 (const T &m)
| Matrix4 ()
| Matrix4 (scalar_type n)
| Matrix4 (scalar_type e00, scalar_type e01, scalar_type e02, scalar_type e03, scalar_type e10, scalar_type e11, scalar_type e12, scalar_type e13, scalar_type e20, scalar_type e21, scalar_type e22, scalar_type e23, scalar_type e30, scalar_type e31, scalar_type e32, scalar_type e33)
const scalar_type & | e (unsigned i, unsigned j) const
scalar_type & | e (unsigned i, unsigned j)
const Vector4< scalar_type > & | operator[] (unsigned int i) const
Vector4< scalar_type > & | operator[] (unsigned int i)
Vector3< scalar_type > | getX () const
Vector3< scalar_type > | getY () const
Vector3< scalar_type > | getZ () const
Vector3< scalar_type > | getT () const
Matrix4 & | setX (const Vector3< scalar_type > &v)
Matrix4 & | setY (const Vector3< scalar_type > &v)
Matrix4 & | setZ (const Vector3< scalar_type > &v)
Matrix4 & | setT (const Vector3< scalar_type > &v)
bool | operator== (const Matrix4 &m) const
bool | operator!= (const Matrix4 &m) const
Matrix4 & | operator= (const Matrix4 &m)
Matrix4 | operator+ (const Matrix4 &m) const
Matrix4 & | operator+= (const Matrix4 &m)
Matrix4 | operator- (const Matrix4 &m) const
Matrix4 & | operator-= (const Matrix4 &m)
Matrix4 & | operator*= (const Matrix4 &m)
Matrix4 | operator- () const
Matrix4 | operator+ (scalar_type d) const
Matrix4 & | operator+= (scalar_type d)
Matrix4 | operator- (scalar_type d) const
Matrix4 & | operator-= (scalar_type d)
Matrix4 | operator* (scalar_type d) const
Matrix4 & | operator*= (scalar_type d)
Matrix4 | operator/ (scalar_type d) const
Matrix4 & | operator/= (scalar_type d)
bool | isIdentity () const
Matrix4 | as3x3 () const
Matrix3< scalar_type > | get3x3 () const
void | set3x3 (const Matrix3< scalar_type > &m)
| This writes only on the upper 3x3 part of the matrix without touching the last row and column.
scalar_type * | ptr ()
const scalar_type * | ptr () const
Matrix4 & | transpose ()
bool | isNull () const
void | setIdentity ()
Matrix4 | inverse (bool *invertible=NULL) const
Matrix4 & | invert (bool *invertible=NULL)
const scalar_type & | e (int i, int j) const
scalar_type & | e (int i, int j)
void | getAsLookAt (Vector3< scalar_type > &eye, Vector3< scalar_type > &look, Vector3< scalar_type > &up, Vector3< scalar_type > &right) const
Matrix4 & | rotate (scalar_type degrees, const Vector3< scalar_type > &v)
Matrix4 & | rotate (scalar_type degrees, scalar_type x, scalar_type y, scalar_type z)
Matrix4 & | rotate (scalar_type degrees1, const Vector3< scalar_type > &v1, scalar_type degrees2, const Vector3< scalar_type > &v2)
void | getYXRotationAngles (scalar_type &degrees_y, scalar_type &degrees_x) const
| If this matrix can be represented as `RY(degrees_y)` * `RX(degrees_x)`, where RX and RY are rotation matrices around the X and Y axis respectively, this function returns the rotation angles `degrees_y` and `degrees_x`.
Matrix4 & | rotate (scalar_type degrees1, const Vector3< scalar_type > &v1, scalar_type degrees2, const Vector3< scalar_type > &v2, scalar_type degrees3, const Vector3< scalar_type > &v3)
Matrix4 & | rotateXYZ (scalar_type degX, scalar_type degY, scalar_type degZ)
Matrix4 & | rotateZYX (scalar_type degZ, scalar_type degY, scalar_type degX)
Matrix4 & | rotate (const Vector4< scalar_type > &from, const Vector4< scalar_type > &to)
Matrix4 & | rotate (const Vector3< scalar_type > &from, const Vector3< scalar_type > &to)
Matrix4 & | translate (scalar_type x, scalar_type y, scalar_type z)
Matrix4 & | translate (const Vector3< scalar_type > &v)
Matrix4 & | scale (scalar_type x, scalar_type y, scalar_type z)
## Static Public Member Functions
static Matrix4 | perspective (scalar_type fovy, scalar_type aspect_ratio, scalar_type znear, scalar_type zfar)
static Matrix4 | frustum (scalar_type pleft, scalar_type pright, scalar_type pbottom, scalar_type ptop, scalar_type pnear, scalar_type pfar)
static Matrix4 | ortho (scalar_type pleft, scalar_type pright, scalar_type pbottom, scalar_type ptop, scalar_type pnear, scalar_type pfar)
static Matrix4 | ortho2D (scalar_type pleft, scalar_type pright, scalar_type pbottom, scalar_type ptop)
static Matrix4 | lookAt (const Vector3< scalar_type > &eye, const Vector3< scalar_type > &look, const Vector3< scalar_type > &up)
static Matrix4 | rotation (scalar_type degrees, scalar_type x, scalar_type y, scalar_type z)
static Matrix4 | rotation (scalar_type degrees, const Vector3< scalar_type > &v)
static Matrix4 | rotation (scalar_type degrees1, const Vector3< scalar_type > &v1, scalar_type degrees2, const Vector3< scalar_type > &v2)
static Matrix4 | rotation (scalar_type degrees1, const Vector3< scalar_type > &v1, scalar_type degrees2, const Vector3< scalar_type > &v2, scalar_type degrees3, const Vector3< scalar_type > &v3)
static Matrix4 | rotationXYZ (scalar_type degX, scalar_type degY, scalar_type degZ)
static Matrix4 | rotationZYX (scalar_type degZ, scalar_type degY, scalar_type degX)
static Matrix4 | rotation (const Vector4< scalar_type > &from, const Vector4< scalar_type > &to)
static Matrix4 | rotation (const Vector3< scalar_type > &from, const Vector3< scalar_type > &to)
static Matrix4 | translation (const Vector3< scalar_type > &v)
static Matrix4 | translation (scalar_type x, scalar_type y, scalar_type z)
static Matrix4 | scaling (const Vector3< scalar_type > &v)
static Matrix4 | scaling (scalar_type x, scalar_type y, scalar_type z)
## Protected Attributes
Vector4< scalar_type > | mVec [4]

## Detailed Description

### template<typename scalar_type>
class vl::Matrix4< scalar_type >

The Matrix4 class is a template class that implements a generic 4x4 matrix, see also vl::dmat4, vl::fmat4, vl::umat4, vl::imat4.

See also:
  Vector4, Vector3, Vector2, Matrix3, Matrix2

## Constructor & Destructor Documentation

template<typename scalar_type>
template<typename T >

vl::Matrix4< scalar_type >::Matrix4 | ( | const T & | m | ) | `[inline, explicit]`

template<typename scalar_type>

vl::Matrix4< scalar_type >::Matrix4 | ( |  | ) | `[inline]`

template<typename scalar_type>

vl::Matrix4< scalar_type >::Matrix4 | ( | scalar_type | n | ) | `[inline]`

template<typename scalar_type>

vl::Matrix4< scalar_type >::Matrix4 | ( | scalar_type | e00,
|  | scalar_type | e01,
|  | scalar_type | e02,
|  | scalar_type | e03,
|  | scalar_type | e10,
|  | scalar_type | e11,
|  | scalar_type | e12,
|  | scalar_type | e13,
|  | scalar_type | e20,
|  | scalar_type | e21,
|  | scalar_type | e22,
|  | scalar_type | e23,
|  | scalar_type | e30,
|  | scalar_type | e31,
|  | scalar_type | e32,
|  | scalar_type | e33 |
| ) |  |  | `[inline, explicit]`

## Member Function Documentation

template<typename scalar_type>

const scalar_type& vl::Matrix4< scalar_type >::e | ( | unsigned | i,
|  | unsigned | j |
| ) |  |  | const`[inline]`

template<typename scalar_type>

scalar_type& vl::Matrix4< scalar_type >::e | ( | unsigned | i,
|  | unsigned | j |
| ) |  |  | `[inline]`

template<typename scalar_type>

const Vector4<scalar_type>& vl::Matrix4< scalar_type >::operator[] | ( | unsigned int | i | ) | const`[inline]`

template<typename scalar_type>

Vector4<scalar_type>& vl::Matrix4< scalar_type >::operator[] | ( | unsigned int | i | ) | `[inline]`

template<typename scalar_type>

Vector3<scalar_type> vl::Matrix4< scalar_type >::getX | ( |  | ) | const`[inline]`

template<typename scalar_type>

Vector3<scalar_type> vl::Matrix4< scalar_type >::getY | ( |  | ) | const`[inline]`

template<typename scalar_type>

Vector3<scalar_type> vl::Matrix4< scalar_type >::getZ | ( |  | ) | const`[inline]`

template<typename scalar_type>

Vector3<scalar_type> vl::Matrix4< scalar_type >::getT | ( |  | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::setX | ( | const Vector3< scalar_type > & | v | ) | `[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::setY | ( | const Vector3< scalar_type > & | v | ) | `[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::setZ | ( | const Vector3< scalar_type > & | v | ) | `[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::setT | ( | const Vector3< scalar_type > & | v | ) | `[inline]`

template<typename scalar_type>

bool vl::Matrix4< scalar_type >::operator== | ( | const Matrix4< scalar_type > & | m | ) | const`[inline]`

template<typename scalar_type>

bool vl::Matrix4< scalar_type >::operator!= | ( | const Matrix4< scalar_type > & | m | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::operator= | ( | const Matrix4< scalar_type > & | m | ) | `[inline]`

template<typename scalar_type>

Matrix4 vl::Matrix4< scalar_type >::operator+ | ( | const Matrix4< scalar_type > & | m | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::operator+= | ( | const Matrix4< scalar_type > & | m | ) | `[inline]`

template<typename scalar_type>

Matrix4 vl::Matrix4< scalar_type >::operator- | ( | const Matrix4< scalar_type > & | m | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::operator-= | ( | const Matrix4< scalar_type > & | m | ) | `[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::operator*= | ( | const Matrix4< scalar_type > & | m | ) | `[inline]`

template<typename scalar_type>

Matrix4 vl::Matrix4< scalar_type >::operator- | ( |  | ) | const`[inline]`

template<typename scalar_type>

Matrix4 vl::Matrix4< scalar_type >::operator+ | ( | scalar_type | d | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::operator+= | ( | scalar_type | d | ) | `[inline]`

template<typename scalar_type>

Matrix4 vl::Matrix4< scalar_type >::operator- | ( | scalar_type | d | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::operator-= | ( | scalar_type | d | ) | `[inline]`

template<typename scalar_type>

Matrix4 vl::Matrix4< scalar_type >::operator* | ( | scalar_type | d | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::operator*= | ( | scalar_type | d | ) | `[inline]`

template<typename scalar_type>

Matrix4 vl::Matrix4< scalar_type >::operator/ | ( | scalar_type | d | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::operator/= | ( | scalar_type | d | ) | `[inline]`

template<typename scalar_type>

bool vl::Matrix4< scalar_type >::isIdentity | ( |  | ) | const`[inline]`

template<typename scalar_type>

Matrix4 vl::Matrix4< scalar_type >::as3x3 | ( |  | ) | const`[inline]`

template<typename scalar_type>

Matrix3<scalar_type> vl::Matrix4< scalar_type >::get3x3 | ( |  | ) | const`[inline]`

template<typename scalar_type>

void vl::Matrix4< scalar_type >::set3x3 | ( | const Matrix3< scalar_type > & | m | ) | `[inline]`

This writes only on the upper 3x3 part of the matrix without touching the last row and column.

template<typename scalar_type>

scalar_type* vl::Matrix4< scalar_type >::ptr | ( |  | ) | `[inline]`

template<typename scalar_type>

const scalar_type* vl::Matrix4< scalar_type >::ptr | ( |  | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::transpose | ( |  | ) | `[inline]`

template<typename scalar_type>

bool vl::Matrix4< scalar_type >::isNull | ( |  | ) | const`[inline]`

template<typename scalar_type>

void vl::Matrix4< scalar_type >::setIdentity | ( |  | ) | `[inline]`

template<typename scalar_type >

Matrix4< scalar_type > vl::Matrix4< scalar_type >::inverse | ( | bool * | invertible = `NULL` | ) | const`[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::invert | ( | bool * | invertible = `NULL` | ) | `[inline]`

template<typename scalar_type>

const scalar_type& vl::Matrix4< scalar_type >::e | ( | int | i,
|  | int | j |
| ) |  |  | const`[inline]`

template<typename scalar_type>

scalar_type& vl::Matrix4< scalar_type >::e | ( | int | i,
|  | int | j |
| ) |  |  | `[inline]`

template<typename scalar_type>

Matrix4< scalar_type > vl::Matrix4< scalar_type >::perspective | ( | scalar_type | fovy,
|  | scalar_type | aspect_ratio,
|  | scalar_type | znear,
|  | scalar_type | zfar |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4< scalar_type > vl::Matrix4< scalar_type >::frustum | ( | scalar_type | pleft,
|  | scalar_type | pright,
|  | scalar_type | pbottom,
|  | scalar_type | ptop,
|  | scalar_type | pnear,
|  | scalar_type | pfar |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4< scalar_type > vl::Matrix4< scalar_type >::ortho | ( | scalar_type | pleft,
|  | scalar_type | pright,
|  | scalar_type | pbottom,
|  | scalar_type | ptop,
|  | scalar_type | pnear,
|  | scalar_type | pfar |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4< scalar_type > vl::Matrix4< scalar_type >::ortho2D | ( | scalar_type | pleft,
|  | scalar_type | pright,
|  | scalar_type | pbottom,
|  | scalar_type | ptop |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4< scalar_type > vl::Matrix4< scalar_type >::lookAt | ( | const Vector3< scalar_type > & | eye,
|  | const Vector3< scalar_type > & | look,
|  | const Vector3< scalar_type > & | up |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

void vl::Matrix4< scalar_type >::getAsLookAt | ( | Vector3< scalar_type > & | eye,
|  | Vector3< scalar_type > & | look,
|  | Vector3< scalar_type > & | up,
|  | Vector3< scalar_type > & | right |
| ) |  |  | const`[inline]`

template<typename scalar_type>

Matrix4< scalar_type > vl::Matrix4< scalar_type >::rotation | ( | scalar_type | degrees,
|  | scalar_type | x,
|  | scalar_type | y,
|  | scalar_type | z |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::rotation | ( | scalar_type | degrees,
|  | const Vector3< scalar_type > & | v |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::rotation | ( | scalar_type | degrees1,
|  | const Vector3< scalar_type > & | v1,
|  | scalar_type | degrees2,
|  | const Vector3< scalar_type > & | v2 |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::rotation | ( | scalar_type | degrees1,
|  | const Vector3< scalar_type > & | v1,
|  | scalar_type | degrees2,
|  | const Vector3< scalar_type > & | v2,
|  | scalar_type | degrees3,
|  | const Vector3< scalar_type > & | v3 |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::rotate | ( | scalar_type | degrees,
|  | const Vector3< scalar_type > & | v |
| ) |  |  | `[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::rotate | ( | scalar_type | degrees,
|  | scalar_type | x,
|  | scalar_type | y,
|  | scalar_type | z |
| ) |  |  | `[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::rotate | ( | scalar_type | degrees1,
|  | const Vector3< scalar_type > & | v1,
|  | scalar_type | degrees2,
|  | const Vector3< scalar_type > & | v2 |
| ) |  |  | `[inline]`

template<typename scalar_type>

void vl::Matrix4< scalar_type >::getYXRotationAngles | ( | scalar_type & | degrees_y,
|  | scalar_type & | degrees_x |
| ) |  |  | const`[inline]`

If this matrix can be represented as `RY(degrees_y)` * `RX(degrees_x)`, where RX and RY are rotation matrices around the X and Y axis respectively, this function returns the rotation angles `degrees_y` and `degrees_x`.

Note:
  This function can only retrieve angles that satisfy the following conditions:
  - -180 <= degrees_y <= 180
  - -180 <= degrees_x <= 180 and degrees_x != 90

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::rotate | ( | scalar_type | degrees1,
|  | const Vector3< scalar_type > & | v1,
|  | scalar_type | degrees2,
|  | const Vector3< scalar_type > & | v2,
|  | scalar_type | degrees3,
|  | const Vector3< scalar_type > & | v3 |
| ) |  |  | `[inline]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::rotationXYZ | ( | scalar_type | degX,
|  | scalar_type | degY,
|  | scalar_type | degZ |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::rotateXYZ | ( | scalar_type | degX,
|  | scalar_type | degY,
|  | scalar_type | degZ |
| ) |  |  | `[inline]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::rotationZYX | ( | scalar_type | degZ,
|  | scalar_type | degY,
|  | scalar_type | degX |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::rotateZYX | ( | scalar_type | degZ,
|  | scalar_type | degY,
|  | scalar_type | degX |
| ) |  |  | `[inline]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::rotation | ( | const Vector4< scalar_type > & | from,
|  | const Vector4< scalar_type > & | to |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4< scalar_type > vl::Matrix4< scalar_type >::rotation | ( | const Vector3< scalar_type > & | from,
|  | const Vector3< scalar_type > & | to |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::rotate | ( | const Vector4< scalar_type > & | from,
|  | const Vector4< scalar_type > & | to |
| ) |  |  | `[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::rotate | ( | const Vector3< scalar_type > & | from,
|  | const Vector3< scalar_type > & | to |
| ) |  |  | `[inline]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::translation | ( | const Vector3< scalar_type > & | v | ) | `[inline, static]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::translation | ( | scalar_type | x,
|  | scalar_type | y,
|  | scalar_type | z |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::translate | ( | scalar_type | x,
|  | scalar_type | y,
|  | scalar_type | z |
| ) |  |  | `[inline]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::translate | ( | const Vector3< scalar_type > & | v | ) | `[inline]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::scaling | ( | const Vector3< scalar_type > & | v | ) | `[inline, static]`

template<typename scalar_type>

static Matrix4 vl::Matrix4< scalar_type >::scaling | ( | scalar_type | x,
|  | scalar_type | y,
|  | scalar_type | z |
| ) |  |  | `[inline, static]`

template<typename scalar_type>

Matrix4& vl::Matrix4< scalar_type >::scale | ( | scalar_type | x,
|  | scalar_type | y,
|  | scalar_type | z |
| ) |  |  | `[inline]`

## Member Data Documentation

template<typename scalar_type>

Vector4<scalar_type> vl::Matrix4< scalar_type >::mVec[4]`[protected]`

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

- E:/VisualizationLibrary/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vl/Matrix4.hpp

Visualization Library v2009.08 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Sun Nov 8 14:29:00 2009.
Permission is granted to use this page to write and publish articles regarding Visualization Library.