- Main Page
- Classes
- Files
- Directories

- Class List
- Class Hierarchy
- Class Members

# cMatrixGL Struct Reference

CHAI describes rotations using 3x3 rotation matrices (cMatrix3d) and 3D vectors (cVector3d) to express position or translation. On the OpenGL side 4x4 matrices are required to perform all geometrical transformations. cMatrixGL provides a structure which encapsulates all the necessary functionality to generate 4x4 OpenGL transformation matrices from 3D position vectors and rotation matrices. More...

`#include <CMacrosGL.h>`

List of all members.

## Public Member Functions
| cMatrixGL ()
const double * | pMatrix () const
void | set (const cVector3d &a_pos)
cVector3d | getPos () const
cMatrix3d | getRot () const
void | set (const cMatrix3d &a_rot)
void | set (const cVector3d &a_pos, const cMatrix3d &a_rot)
void | copyto (cMatrixGL &a_destination) const
void | copyfrom (const cMatrixGL &a_source)
void | identity ()
void | mul (const cMatrixGL &a_matrix)
void | mulr (const cMatrix3d &a_matrix, cMatrix3d &a_result) const
void | trans ()
void | transr (cMatrixGL &a_result) const
void | buildFrustumMatrix (double l, double r, double b, double t, double n, double f)
bool | invert ()
void | buildPerspectiveMatrix (double fovy, double aspect, double zNear, double zFar)
void | buildLookAtMatrix (double eyex, double eyey, double eyez, double centerx, double centery, double centerz, double upx, double upy, double upz)
void | buildLookAtMatrix (cVector3d &a_eye, cVector3d &a_lookAt, cVector3d a_up)
void | glMatrixPush ()
void | glMatrixLoad ()
void | glMatrixMultiply ()
void | glMatrixPushMultiply ()
void | glMatrixPop ()
void | str (std::string a_string, int a_precision)
## Private Attributes
double | m [4][4]
| array of type double, defining the actual transformation

## Detailed Description

CHAI describes rotations using 3x3 rotation matrices (cMatrix3d) and 3D vectors (cVector3d) to express position or translation. On the OpenGL side 4x4 matrices are required to perform all geometrical transformations. cMatrixGL provides a structure which encapsulates all the necessary functionality to generate 4x4 OpenGL transformation matrices from 3D position vectors and rotation matrices.

cMatrixGL also provides OpenGL calls to push, multiply and pop matrices off the OpenGL stack.

Note that OpenGL Matrices are COLUMN major, but CHAI matrices (and all other matrices in the universe) are ROW major.

## Constructor & Destructor Documentation

cMatrixGL::cMatrixGL | ( |  | ) | `[inline]`

Default constructor

## Member Function Documentation

const double* cMatrixGL::pMatrix | ( |  | ) | const`[inline]`

Returns a pointer to the matrix array in memory.

Returns:
  Returns a pointer of type double.

void cMatrixGL::set | ( | const cVector3d & | a_pos | ) | `[inline]`

Creates OpenGL translation matrix from a position vector passed as parameter.

Parameters:

  | a_pos | Input vector.

cVector3d cMatrixGL::getPos | ( |  | ) | const`[inline]`

Extract the translational component of this matrix

cMatrix3d cMatrixGL::getRot | ( |  | ) | const`[inline]`

Extract the rotational component of this matrix

void cMatrixGL::set | ( | const cMatrix3d & | a_rot | ) | `[inline]`

Create an OpenGL rotation matrix from a 3x3 rotation matrix passed as a parameter.

Parameters:

  | a_rot | The source rotation matrix

void cMatrixGL::set | ( | const cVector3d & | a_pos,
|  | const cMatrix3d & | a_rot |
| ) |  |  | `[inline]`

Create an OpenGL translation matrix from a 3-vector and a 3x3 matrix passed as a parameter.

Parameters:

  | a_pos | Translational component of the transformation
  | a_rot | Rotational component of the transformation

void cMatrixGL::copyto | ( | cMatrixGL & | a_destination | ) | const`[inline]`

Copy the current matrix to an external matrix passed as a parameter

Parameters:

  | a_destination | Destination matrix

void cMatrixGL::copyfrom | ( | const cMatrixGL & | a_source | ) | `[inline]`

Copy values from an external matrix passed as parameter to this matrix

Parameters:

  | a_source | Source matrix

void cMatrixGL::identity | ( |  | ) | `[inline]`

Set this matrix to be equal to the identity matrix.

void cMatrixGL::mul | ( | const cMatrixGL & | a_matrix | ) | `[inline]`

Left-multiply the current matrix by an external matrix passed as a parameter. That is, compute :

this = a_matrix * this;

Remember that all matrices are column-major. That's why the following code looks like right-multiplication...

Parameters:

  | a_matrix | Matrix with which multiplication is performed.

void cMatrixGL::mulr | ( | const cMatrix3d & | a_matrix,
|  | cMatrix3d & | a_result |
| ) |  |  | const`[inline]`

Left-multiply the current matrix by an external matrix passed as a parameter, storing the result externally. That is, compute :

a_result = a_matrix * this;

Remember that all matrices are column-major. That's why the following code looks like right-multiplication...

Parameters:

  | a_matrix | Matrix with which multiplication is performed.
  | a_result | Matrix where the result is stored.

void cMatrixGL::trans | ( |  | ) | `[inline]`

Transpose this matrix.

void cMatrixGL::transr | ( | cMatrixGL & | a_result | ) | const`[inline]`

Transpose this matrix and store the result in a_result

Parameters:

  | a_result | Result is stored here.

void cMatrixGL::buildFrustumMatrix | ( | double | l,
|  | double | r,
|  | double | b,
|  | double | t,
|  | double | n,
|  | double | f |
| ) |  |  | `[inline]`

Create a frustum matrix, as defined by the glFrustum function.

bool cMatrixGL::invert | ( |  | ) | `[inline]`

Invert this matrix.

Returns:
  Return true if operation succeeds. Otherwise false.

void cMatrixGL::buildPerspectiveMatrix | ( | double | fovy,
|  | double | aspect,
|  | double | zNear,
|  | double | zFar |
| ) |  |  | `[inline]`

Build a perspective matrix, according to the gluPerspective function

void cMatrixGL::buildLookAtMatrix | ( | double | eyex,
|  | double | eyey,
|  | double | eyez,
|  | double | centerx,
|  | double | centery,
|  | double | centerz,
|  | double | upx,
|  | double | upy,
|  | double | upz |
| ) |  |  | `[inline]`

Build a 4x4 matrix transform, according to the gluLookAt function

void cMatrixGL::buildLookAtMatrix | ( | cVector3d & | a_eye,
|  | cVector3d & | a_lookAt,
|  | cVector3d | a_up |
| ) |  |  | `[inline]`

Build a 4x4 matrix transform, according to the gluLookAt function

void cMatrixGL::glMatrixPush | ( |  | ) | `[inline]`

Push the current OpenGL matrix stack

void cMatrixGL::glMatrixLoad | ( |  | ) | `[inline]`

Load the current OpenGL matrix with this cMatrixGL matrix

void cMatrixGL::glMatrixMultiply | ( |  | ) | `[inline]`

Multiply the current OpenGL matrix with this cMatrixGL matrix

void cMatrixGL::glMatrixPushMultiply | ( |  | ) | `[inline]`

Push the current OpenGL matrix stack and multiply with this cMatrixGL matrix.

void cMatrixGL::glMatrixPop | ( |  | ) | `[inline]`

Pop current OpenGL matrix off the stack.

void cMatrixGL::str | ( | std::string | a_string,
|  | int | a_precision |
| ) |  |  | `[inline]`

Convert the current matrix into an std::string

Parameters:

  | a_string | String where conversion is stored
  | a_precision | Number of digits

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

- chai3d/src/graphics/CMacrosGL.h