chai3d::cTransform Struct Reference

This class implements a 4D transformation matrix encoded as column-major.

#include <CTransform.h>

Public Member Functions

 cTransform ()
 
 cTransform (const cVector3d &a_pos, const cMatrix3d &a_rot)
 Constructor of cTransform. More...
 
 cTransform (const cVector3d &a_pos)
 Constructor of cTransform. More...
 
 cTransform (const cMatrix3d &a_rot)
 Constructor of cTransform. More...
 
void setLocalPos (const cVector3d &a_pos)
 This method builds a transformation matrix from a position vector. More...
 
void setLocalRot (const cMatrix3d &a_rot)
 This method Builds a transformation matrix from a rotation matrix. More...
 
void set (const cVector3d &a_pos, const cMatrix3d &a_rot)
 This method Builds a transformation matrix from a position vector and a rotation matrix. More...
 
void set (const double &a_00, const double &a_01, const double &a_02, const double &a_03, const double &a_10, const double &a_11, const double &a_12, const double &a_13, const double &a_20, const double &a_21, const double &a_22, const double &a_23, const double &a_30, const double &a_31, const double &a_32, const double &a_33)
 This method sets values to all elements of this transformation matrix. More...
 
void setFrustumMatrix (double a_l, double a_r, double a_b, double a_t, double a_n, double a_f)
 This method creates a frustum matrix. More...
 
void setLookAtMatrix (const double a_eyeX, const double a_eyeY, const double a_eyeZ, const double a_centerX, const double a_centerY, const double a_centerZ, const double a_upX, const double a_upY, const double a_upZ)
 This method build a transformation matrix. More...
 
void setLookAtMatrix (const cVector3d &a_eye, const cVector3d &a_lookAt, const cVector3d &a_up)
 This method build a transformation matrix. More...
 
void setPerspectiveMatrix (const double a_fovy, const double a_aspect, const double a_zNear, const double a_zFar)
 This method builds a perspective matrix. More...
 
double * getData ()
 This method returns a pointer to the matrix array in memory. More...
 
cVector3d getLocalPos () const
 This method returns the translational component of this matrix. More...
 
cMatrix3d getLocalRot () const
 This method returns the rotation component of this matrix. More...
 
void copyto (cTransform &a_destination) const
 This method copies all elements of this matrix to another matrix. More...
 
void copyfrom (const cTransform &a_source)
 This method copies all elements from another matrix to this one. More...
 
void identity ()
 This method builds an identity matrix. More...
 
void mul (const cTransform &a_matrix)
 This method left-multiplies this matrix with a transformation matrix passed as argument. More...
 
void mulr (const cTransform &a_matrix, cTransform &a_result) const
 This method left-multiplies this matrix with a transformation matrix passed as argument. More...
 
void mulr (const cVector3d &a_vector, cVector3d &a_result) const
 This method multiplies this matrix by a vector passed as argument. More...
 
void trans ()
 This method computes the transpose of this matrix. More...
 
void transr (cTransform &a_result) const
 This method computes the transpose of this matrix. More...
 
bool invert ()
 This method computes the inverse of this matrix. More...
 
std::string str (const int a_precision)
 This method converts this matrix to a string representation. More...
 
double & operator() (const int a_index0, const int a_index1)
 An overloaded () operator. More...
 
const double & operator() (const int a_index0, const int a_index1) const
 An overloaded () operator. More...
 

Public Attributes

double m [4][4]
 Transformation matrix data. More...
 
bool m_flagTransform
 If true then matrix encodes a translation and rotation matrix. If false matrix is represents a general 4x4. More...
 

Constructor & Destructor Documentation

chai3d::cTransform::cTransform ( )
inline

Default constructor of cTransform.

chai3d::cTransform::cTransform ( const cVector3d a_pos,
const cMatrix3d a_rot 
)
inline

Builds a transformation matrix from a position vector and rotation matrix passed as arguments.

Parameters
a_posPosition vector.
a_rotRotation matrix.
chai3d::cTransform::cTransform ( const cVector3d a_pos)
inline

Builds a transformation matrix from a position vector passed as argument.

Parameters
a_posPosition vector.
chai3d::cTransform::cTransform ( const cMatrix3d a_rot)
inline

Build transformation matrix from a rotation matrix passed as argument.

Parameters
a_rotRotation matrix.

Member Function Documentation

void chai3d::cTransform::setLocalPos ( const cVector3d a_pos)
inline

This method builds a transformation matrix from a position vector a_pos passed as argument.

Parameters
a_posPosition vector.
void chai3d::cTransform::setLocalRot ( const cMatrix3d a_rot)
inline

This method Builds a transformation matrix from a rotation matrix a_rot passed as argument.

Parameters
a_rotRotation matrix.
void chai3d::cTransform::set ( const cVector3d a_pos,
const cMatrix3d a_rot 
)
inline

This method Builds a transformation matrix from a position vector a_pos and a rotation matrix a_rot passed as arguments.

Parameters
a_posPosition vector.
a_rotRotation matrix.
void chai3d::cTransform::set ( const double &  a_00,
const double &  a_01,
const double &  a_02,
const double &  a_03,
const double &  a_10,
const double &  a_11,
const double &  a_12,
const double &  a_13,
const double &  a_20,
const double &  a_21,
const double &  a_22,
const double &  a_23,
const double &  a_30,
const double &  a_31,
const double &  a_32,
const double &  a_33 
)
inline

This method sets values passed as arguments to all elements of this transformation matrix.

Parameters
a_00Matrix element (0,0).
a_01Matrix element (0,1).
a_02Matrix element (0,2).
a_03Matrix element (0,3).
a_10Matrix element (1,0).
a_11Matrix element (1,1).
a_12Matrix element (1,2).
a_13Matrix element (1,3).
a_20Matrix element (2,0).
a_21Matrix element (2,1).
a_22Matrix element (2,2).
a_23Matrix element (2,3).
a_30Matrix element (3,0).
a_31Matrix element (3,1).
a_32Matrix element (3,2).
a_33Matrix element (3,3).
void chai3d::cTransform::setFrustumMatrix ( double  a_l,
double  a_r,
double  a_b,
double  a_t,
double  a_n,
double  a_f 
)
inline

This method creates a frustum matrix, as defined by the OpenGL glFrustum() function.

Parameters
a_lSpecifies the coordinate for the left clipping plane.
a_rSpecifies the coordinate for the right plane.
a_bSpecifies the coordinate for the bottom and top horizontal clipping plane.
a_tSpecifies the coordinate for the top horizontal clipping plane.
a_nSpecifies the distance to the near depth clipping plane. Distance must be positive.
a_fSpecifies the distance to the far depth clipping plane. Distance must be positive.
void chai3d::cTransform::setLookAtMatrix ( const double  a_eyeX,
const double  a_eyeY,
const double  a_eyeZ,
const double  a_centerX,
const double  a_centerY,
const double  a_centerZ,
const double  a_upX,
const double  a_upY,
const double  a_upZ 
)
inline

This method build a transformation matrix, according to the OpenGL gluLookAt() function.

Parameters
a_eyeXSpecifies the position of the eye point.
a_eyeYSpecifies the position of the eye point.
a_eyeZSpecifies the position of the eye point.
a_centerXSpecifies the position of the reference point.
a_centerYSpecifies the position of the reference point.
a_centerZSpecifies the position of the reference point.
a_upXSpecifies the direction of the up vector.
a_upYSpecifies the direction of the up vector.
a_upZSpecifies the direction of the up vector.
void chai3d::cTransform::setLookAtMatrix ( const cVector3d a_eye,
const cVector3d a_lookAt,
const cVector3d a_up 
)
inline

This method build a transformation matrix, according to the OpenGL gluLookAt() function.

Parameters
a_eyeSpecifies the position of the eye point.
a_lookAtSpecifies the position of the reference point.
a_upSpecifies the direction of the up vector.
void chai3d::cTransform::setPerspectiveMatrix ( const double  a_fovy,
const double  a_aspect,
const double  a_zNear,
const double  a_zFar 
)
inline

This method builds a perspective matrix, according to the OpenGL gluPerspective() function.

Parameters
a_fovySpecifies the field of view angle, in degrees, in the y direction.
a_aspectSpecifies the aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height).
a_zNearSpecifies the distance from the viewer to the near clipping plane (always positive).
a_zFarSpecifies the distance from the viewer to the far clipping plane (always positive).
double* chai3d::cTransform::getData ( )
inline

This method returns a pointer to the matrix array in memory.

Returns
Pointer to data array.
cVector3d chai3d::cTransform::getLocalPos ( ) const
inline

This method returns the translational component of this matrix.

Returns
Position vector.
cMatrix3d chai3d::cTransform::getLocalRot ( ) const
inline

This method returns the rotation component of this matrix.

Returns
Rotation matrix.
void chai3d::cTransform::copyto ( cTransform a_destination) const
inline

This method copies all elements of this matrix to another matrix a_destination passed as argument.

a_destination = this
Parameters
a_destinationDestination matrix.
void chai3d::cTransform::copyfrom ( const cTransform a_source)
inline

This method copies all elements of a matrix a_source passed as argument to this one.

this = a_source
Parameters
a_sourceSource matrix.
void chai3d::cTransform::identity ( )
inline

This method builds an identity matrix with ones on the main diagonal and zeros elsewhere.

void chai3d::cTransform::mul ( const cTransform a_matrix)
inline

This method left-multiplies this matrix with a transformation matrix a_matrix passed as argument.
The result of this operation is stored in this matrix overwriting previous values.

this = this * a_matrix
Parameters
a_matrixInput matrix.
void chai3d::cTransform::mulr ( const cTransform a_matrix,
cTransform a_result 
) const
inline

This method left-multiplies this matrix with a transformation matrix a_matrix passed as argument.
The result of this operation is stored in matrix a_result passed as second argument.

a_result = this * a_matrix
Parameters
a_matrixInput matrix.
a_resultResult matrix.
void chai3d::cTransform::mulr ( const cVector3d a_vector,
cVector3d a_result 
) const
inline

This method multiplies this matrix by a vector a_vector passed as argument.
The result of this operation is stored in vector a_result passed as second argument.

a_result = this * a_matrix
Parameters
a_vectorInput vector.
a_resultMatrix where the result is stored.
void chai3d::cTransform::trans ( )
inline

This method computes the transpose of this matrix.
The result of this operation is stored in this matrix overwriting previous values.

void chai3d::cTransform::transr ( cTransform a_result) const
inline

This method computes the transpose of this matrix.
The result of this operation is stored in the result matrix a_result matrix passed as argument.

Parameters
a_resultOutput matrix.
bool chai3d::cTransform::invert ( )
inline

This method computes the inverse of this matrix.
If the operation succeeds, the result is stored in this matrix.

Returns
true if operation succeeds, false otherwise.
std::string chai3d::cTransform::str ( const int  a_precision)
inline

This method converts this matrix to a string representation. The output springs displays the three column vectors of matrix.
The number of digits after the decimal point are set by argument a_precision.

Parameters
a_precisionNumber of digits.
Returns
Converted matrix in string format.
double& chai3d::cTransform::operator() ( const int  a_index0,
const int  a_index1 
)
inline
const double& chai3d::cTransform::operator() ( const int  a_index0,
const int  a_index1 
) const
inline

Member Data Documentation

double chai3d::cTransform::m[4][4]
bool chai3d::cTransform::m_flagTransform

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