GL Studio SCECpp Runtime Library
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
GlsMatrixAffineD Class Reference

#include <gls_matrix_affine_double.h>

Public Types

enum  RotationAxis { ROTATION_AXIS_X, ROTATION_AXIS_Y, ROTATION_AXIS_Z }
 
typedef GlsFloat64 CStyleMatrix[DIMENSION][DIMENSION]
 
typedef GLfloat GLMatrixAffineF[DIMENSION *DIMENSION]
 

Public Member Functions

 GlsMatrixAffineD (void)
 
 GlsMatrixAffineD (const GlsMatrixAffineD &m)
 
 GlsMatrixAffineD (const CStyleMatrix &m)
 
 ~GlsMatrixAffineD ()
 
void SetMatrix (const GlsMatrixAffineD &m)
 
void SetElement (const GlsUInt32 row, const GlsUInt32 col, const GlsFloat64 val)
 
GlsFloat64 GetElement (const GlsUInt32 row, const GlsUInt32 col) const
 
void LeftMultiply (const GlsMatrixAffineD &m)
 
void RightMultiply (const GlsMatrixAffineD &m)
 
void Rotate (const GlsFloat64 angle, const RotationAxis rotationAxis)
 
void Translate (const GlsVector3D &v)
 
void PopulateGLMatrixAffineF (GLMatrixAffineF &dst) const
 

Static Public Member Functions

static GlsBool CStyleMatrixIsIdentity (const CStyleMatrix &m)
 
static GlsBool GLMatrixAffineFIsIdentity (const GLMatrixAffineF &m)
 
static void CopyGLMatrixAffineF (GLMatrixAffineF &dst, const GLMatrixAffineF &src)
 
static void VectorMultGLMatrixAffineF (const GLMatrixAffineF &m, const GlsHomogeneousVector3D &v, GlsHomogeneousVector3D &dst)
 
static void MatrixMultGLMatrixAffineF (const GLMatrixAffineF &lhs, const GLMatrixAffineF &rhs, GLMatrixAffineF &result)
 

Static Public Attributes

static const GlsUInt32 DIMENSION = 4u
 
static const GLMatrixAffineF IDENTITY_MATRIX_GL
 

Protected Member Functions

void Initialize (void)
 
void MakeIdentity (void)
 
void Multiply (const GlsMatrixAffineD &lhs, const GlsMatrixAffineD &rhs, GlsMatrixAffineD &result) const
 

Protected Attributes

GlsFloat64 _data [DIMENSION *DIMENSION]
 
GlsFloat64_matrix [DIMENSION]
 

Static Protected Attributes

static const GlsMatrixAffineD::CStyleMatrix IDENTITY_MATRIX_C_STYLE
 
static const GlsFloat64 IDENTITY_MATRIX_DATA_REP [DIMENSION *DIMENSION]
 

Detailed Description

4x4 affine transformation matrix. It provides the ability to perform rotations, and translations. Results are cumulative, i.e. every rotate and translate call transforms the terms that already exist in the matrix.

Invariant
_matrix column array points to _data array, each element of the data array is a valid floating point value

Member Typedef Documentation

typedef GlsFloat64 GlsMatrixAffineD::CStyleMatrix[DIMENSION][DIMENSION]

C style matrix representation

typedef GLfloat GlsMatrixAffineD::GLMatrixAffineF[DIMENSION *DIMENSION]

affine matrix of floats in format suitable for GL

Member Enumeration Documentation

enumeration describing axes of rotation

Enumerator
ROTATION_AXIS_X 

X axis

ROTATION_AXIS_Y 

Y axis

ROTATION_AXIS_Z 

Z axis

Constructor & Destructor Documentation

GlsMatrixAffineD::GlsMatrixAffineD ( void  )

Default constructor. The new matrix will be the identity matrix.

Precondition
none
Postcondition
object created, matrix is identity matrix
GlsMatrixAffineD::GlsMatrixAffineD ( const GlsMatrixAffineD m)

Copy Constructor.

Parameters
mmatrix to copy.
Precondition
none
Postcondition
matrix is equal to m
GlsMatrixAffineD::GlsMatrixAffineD ( const CStyleMatrix m)

Constructor - initialize from a CStyleMatrix

Parameters
mc style matrix with intial matrix values
Precondition
GlsMatrixAffineDCStyleMatrixIsValid( m )
Postcondition
instance created, matrix is equal to m
GlsMatrixAffineD::~GlsMatrixAffineD ( )

Destructor - destroy instance

Precondition
none
Postcondition
instance destroyed

Member Function Documentation

static void GlsMatrixAffineD::CopyGLMatrixAffineF ( GLMatrixAffineF dst,
const GLMatrixAffineF src 
)
static

Copy a GLMatrixAffineF

Parameters
dst[out] destination GLMatrixAffineF
srcsource GLMatrixAffineF
Precondition
GLMatrixAffineFIsValid( src )
Postcondition
dst is a copy of src
static GlsBool GlsMatrixAffineD::CStyleMatrixIsIdentity ( const CStyleMatrix m)
static

Determine if the given c style matrix is the identity matrix

Parameters
mc style matrix in question
Returns
GLS_TRUE if identity else GLS_FALSE
Precondition
GlsMatrixAffineDCStyleMatrixIsValid( m )
Postcondition
none
GlsFloat64 GlsMatrixAffineD::GetElement ( const GlsUInt32  row,
const GlsUInt32  col 
) const

Get the element in the matrix at the given row and column

Parameters
rowzero based row of element ( < DIMENSION )
colzero based column of element ( < DIMENSION )
Returns
element at given row and column
Precondition
row < DIMENSION, col < DIMENSION
Postcondition
none
static GlsBool GlsMatrixAffineD::GLMatrixAffineFIsIdentity ( const GLMatrixAffineF m)
static

Determine if the given GL matrix is identity

Parameters
mmatrix in question
Returns
GLS_TRUE if , is identity else GLS_FALSE
Precondition
GLMatrixAffineFIsValid( m )
Postcondition
none
void GlsMatrixAffineD::Initialize ( void  )
protected

This should be called from all constructors, as it initializes the matrix column index so that matrix elements can be addressed in two dimensions, but a multiplication is not incurred when doing so.

Precondition
none
Postcondition
_matrix elements are initialized
void GlsMatrixAffineD::LeftMultiply ( const GlsMatrixAffineD m)

Multiply this matrix by m where this matrix is on the left side and and m is on the right side of the multiplication, ( *this = (*this) * m )

Parameters
mmatrix to multiply by
Precondition
none
Postcondition
this matrix is multiplied by m ( *this * m )
void GlsMatrixAffineD::MakeIdentity ( void  )
protected

Set this matrix to the identity matrix. The identity matrix is I = [Aij], where Aii = 1 and Aij = 0 for i != j. Thus, for the identity matrix, the terms off the main diagonal are all zero, and the terms on the main diagonal are all one.

Precondition
none
Postcondition
matrix is identity matrix
static void GlsMatrixAffineD::MatrixMultGLMatrixAffineF ( const GLMatrixAffineF lhs,
const GLMatrixAffineF rhs,
GLMatrixAffineF result 
)
static

Multiply two GL matrices ( lhs, rhs ) and store in result result = ( lhs * rhs )

Parameters
lhsleft hand side of multiplication
rhsright hand side of multiplication
result[out] gets resultant matrix form multiplication
Precondition
GLMatrixAffineFIsValid( lhs ), GLMatrixAffineFIsValid( rhs )
Postcondition
result = ( lhs * rhs )
void GlsMatrixAffineD::Multiply ( const GlsMatrixAffineD lhs,
const GlsMatrixAffineD rhs,
GlsMatrixAffineD result 
) const
protected

Multiply the two matrices ( lhs, rhs ) and store in result ( result = ( lhs * rhs )

Parameters
lhsleft hand side of multiplication
rhsright hand side of multiplication
result[out] gets resultant matrix for multiplication
Precondition
none
Postcondition
result = ( lhs * rhs )
void GlsMatrixAffineD::PopulateGLMatrixAffineF ( GLMatrixAffineF dst) const

populate the given GLMatrixAffineF with the values of the matrix

Parameters
dst[out] gets values of the matrix
Precondition
none
Postcondition
dst contains values of the matrix
void GlsMatrixAffineD::RightMultiply ( const GlsMatrixAffineD m)

Multiply this matrix by m where this matrix is on the right side and and m is on the left side of the multiplication, ( *this = m * (*this) )

Parameters
mmatrix to multiply by
Precondition
none
Postcondition
this matrix is multiplied by m ( m * *this )
void GlsMatrixAffineD::Rotate ( const GlsFloat64  angle,
const RotationAxis  rotationAxis 
)

Perform a rotation transformation around a major axis around the origin, and combine this transformation with the existing matrix data.

Parameters
anglerotation angle in degrees
rotationAxismajor axis of rotation
Precondition
GlsFloatIsValid( angle ), GlsMatrixAffineDRotationAxisIsValid( rotationAxis )
Postcondition
matrix is rotation transformed
void GlsMatrixAffineD::SetElement ( const GlsUInt32  row,
const GlsUInt32  col,
const GlsFloat64  val 
)

Set the element in the matrix at the given row and column

Parameters
rowzero based row of element ( < DIMENSION )
colzero based column of element ( < DIMENSION )
valnew value for element
Precondition
row < DIMENSION, col < DIMENSION, GlsFloatIsValid( val )
Postcondition
element at row and column is set to new value
void GlsMatrixAffineD::SetMatrix ( const GlsMatrixAffineD m)

copy given matrix

Parameters
mmatrix in question
Precondition
none
Postcondition
matrix elements are equal to matrix elements of m
void GlsMatrixAffineD::Translate ( const GlsVector3D v)

Perform a translation using the given 3D vector and combine with this matrix

Parameters
v3D vector in question
Precondition
v.IsValid()
Postcondition
matrix is translated by v
static void GlsMatrixAffineD::VectorMultGLMatrixAffineF ( const GLMatrixAffineF m,
const GlsHomogeneousVector3D v,
GlsHomogeneousVector3D dst 
)
static

Multiply the given 3D homogeneous vector by the given GL matrix

Parameters
mGL matrix in question
v3D homogeneous vector in question
dst[out] receives result ( m * v )
Precondition
GLMatrixAffineFIsValid( m ), v.IsValid()
Postcondition
dst = m * v

Member Data Documentation

GlsFloat64 GlsMatrixAffineD::_data[DIMENSION *DIMENSION]
protected

This is the actual matrix data stored in column-major ordering in a one-dimensional array of the appropriate size to store all matrix terms. The data is stored in this manner so that it can be passed to OpenGL matrix operations, which expect matrices to be ordered this way.

GlsFloat64* GlsMatrixAffineD::_matrix[DIMENSION]
protected

A column index array. Each element in this array "points" to a column of the matrix within the above data. By using this index, we can address matrix terms using two dimensions, column and row, without incurring a multiplication. Eg. matrix[0] points to a column within data, which is the address of the first term in the column. We can further address into the column and access a particular row by adding another dimension, eg. matrix[0][1]. The indices must be set up at construction time.

const GlsUInt32 GlsMatrixAffineD::DIMENSION = 4u
static

matrix is DIMENSION x DIMENSION

const GlsMatrixAffineD::CStyleMatrix GlsMatrixAffineD::IDENTITY_MATRIX_C_STYLE
staticprotected

identity c style matrix

const GlsFloat64 GlsMatrixAffineD::IDENTITY_MATRIX_DATA_REP[DIMENSION *DIMENSION]
staticprotected

identity matrix in data representation format

const GLMatrixAffineF GlsMatrixAffineD::IDENTITY_MATRIX_GL
static

identity GLMatrixAffineF matrix ( column major )