3D matrix More...

#include <mat2.h>

Public Member Functions

 Mat3 ()
 Constructs a 3x3 matrix (zero'ed) More...
 
 Mat3 (const Mat3< Type > &copy)
 Constructs a 3x3 matrix (copied) More...
 
 Mat3 (const Mat2< Type > &copy)
 Constructs a 3x3 matrix (copied from a 2d matrix) More...
 
 Mat3 (const Mat4< Type > &copy)
 Constructs a 3x3 matrix (copied from a 4d matrix) More...
 
 Mat3 (const float *init_matrix)
 Constructs a 3x3 matrix (copied from 9 floats) More...
 
 Mat3 (Type m00, Type m01, Type m02, Type m10, Type m11, Type m12, Type m20, Type m21, Type m22)
 Constructs a 3x3 matrix (copied from specified values) More...
 
 Mat3 (const double *init_matrix)
 Constructs a 3x3 matrix (copied from 9 doubles) More...
 
 Mat3 (const int64_t *init_matrix)
 Constructs a 3x3 matrix (copied from 9, 64 bit integers) More...
 
 Mat3 (const int32_t *init_matrix)
 Constructs a 3x3 matrix (copied from 9, 32 bit integers) More...
 
 Mat3 (const int16_t *init_matrix)
 Constructs a 3x3 matrix (copied from 9, 16 bit integers) More...
 
 Mat3 (const int8_t *init_matrix)
 Constructs a 3x3 matrix (copied from 9, 8 bit integers) More...
 
Mat3< Type > & adjoint ()
 Creates the adjoint (or known as adjugate) of the matrix. More...
 
double det () const
 Calculate the matrix determinant. More...
 
Mat3< Type > & inverse ()
 Create the matrix inverse. (Returns a zero matrix if the determinent = 0) More...
 
bool is_equal (const Mat3< Type > &other, Type epsilon) const
 Returns true if equal within the bounds of an epsilon. More...
 
 operator Type * ()
 Operator that returns the matrix as a array. More...
 
 operator Type const * () const
 Operator that returns the matrix as a array. More...
 
bool operator!= (const Mat3< Type > &other)
 Not-equal operator. More...
 
Mat3< Type > operator* (const Mat3< Type > &mult) const
 Multiplication operator. More...
 
Vec2< Type > operator* (const Vec2< Type > &mult) const
 Multiplication operator. More...
 
Mat3< Type > operator+ (const Mat3< Type > &add_matrix) const
 Addition operator. More...
 
Mat3< Type > operator- (const Mat3< Type > &sub_matrix) const
 Subtraction operator. More...
 
Mat3< Type > & operator= (const Mat3< Type > &copy)
 Copy assignment operator. More...
 
Mat3< Type > & operator= (const Mat4< Type > &copy)
 Copy assignment operator. More...
 
Mat3< Type > & operator= (const Mat2< Type > &copy)
 Copy assignment operator. More...
 
bool operator== (const Mat3< Type > &other) const
 Equality operator. More...
 
Type & operator[] (int i)
 Operator that returns the matrix cell at the given index. More...
 
const Type & operator[] (int i) const
 Operator that returns the matrix cell at the given index. More...
 
Type & operator[] (unsigned int i)
 Operator that returns the matrix cell at the given index. More...
 
const Type & operator[] (unsigned int i) const
 Operator that returns the matrix cell at the given index. More...
 
Mat3< Type > & transpose ()
 Calculate the transpose of this matrix. More...
 

Static Public Member Functions

static Mat3< Type > add (const Mat3< Type > &matrix_1, const Mat3< Type > &matrix_2)
 Add 2 matrices. More...
 
static Mat3< Type > adjoint (const Mat3< Type > &matrix)
 Calculate the adjoint (or known as Adjugate or Conjugate Transpose) of a matrix. More...
 
static Mat3< Type > identity ()
 
static Mat3< Type > inverse (const Mat3< Type > &matrix)
 Calculate the matrix inverse of a matrix. More...
 
static bool is_equal (const Mat3< Type > &first, const Mat3< Type > &second, Type epsilon)
 Returns true if equal within the bounds of an epsilon. More...
 
static Mat3< Type > multiply (const Mat3< Type > &matrix_1, const Mat3< Type > &matrix_2)
 Multiply 2 matrices. More...
 
static Mat3< Type > null ()
 
static Mat3< Type > rotate (Type angle, Type x, Type y, Type z, bool normalize=true)
 Create a 3d rotation matrix. More...
 
static Mat3< Type > rotate (float angle, Vec3< Type > rotation, bool normalize=true)
 Create a 3d rotation matrix. More...
 
static Mat3< Type > rotate (Type angle_x, Type angle_y, Type angle_z, EulerOrder order)
 Create a 3d rotation matrix using euler angles. More...
 
static Mat3< Type > rotate (Type angle)
 Create a 2d rotation matrix. More...
 
static Mat3< Type > scale (Type x, Type y)
 Create a 2d scale matrix. More...
 
static Mat3< Type > scale (const Vec3< Type > &xy)
 Create a 2d scale matrix. More...
 
static Mat3< Type > subtract (const Mat3< Type > &matrix_1, const Mat3< Type > &matrix_2)
 Subtract 2 matrices. More...
 
static Mat3< Type > translate (Type x, Type y)
 Create a 2d translation matrix. More...
 
static Mat3< Type > translate (const Vec2< Type > &xy)
 Create a 2d translation matrix. More...
 
static Mat3< Type > transpose (const Mat3< Type > &matrix)
 Calculate the transpose of a matrix. More...
 

Public Attributes

Type matrix [9]
 The matrix (in column-major format) More...
 

Detailed Description

template<typename Type>
class uicore::Mat3< Type >

3D matrix

These matrix templates are defined for: int (Mat3i), float (Mat3f), double (Mat3d)

Constructor & Destructor Documentation

template<typename Type>
uicore::Mat3< Type >::Mat3 ( )
inline

Constructs a 3x3 matrix (zero'ed)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const Mat3< Type > &  copy)
inline

Constructs a 3x3 matrix (copied)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const Mat2< Type > &  copy)
explicit

Constructs a 3x3 matrix (copied from a 2d matrix)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const Mat4< Type > &  copy)
explicit

Constructs a 3x3 matrix (copied from a 4d matrix)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const float *  init_matrix)
inlineexplicit

Constructs a 3x3 matrix (copied from 9 floats)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( Type  m00,
Type  m01,
Type  m02,
Type  m10,
Type  m11,
Type  m12,
Type  m20,
Type  m21,
Type  m22 
)
inlineexplicit

Constructs a 3x3 matrix (copied from specified values)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const double *  init_matrix)
inlineexplicit

Constructs a 3x3 matrix (copied from 9 doubles)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const int64_t *  init_matrix)
inlineexplicit

Constructs a 3x3 matrix (copied from 9, 64 bit integers)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const int32_t *  init_matrix)
inlineexplicit

Constructs a 3x3 matrix (copied from 9, 32 bit integers)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const int16_t *  init_matrix)
inlineexplicit

Constructs a 3x3 matrix (copied from 9, 16 bit integers)

template<typename Type>
uicore::Mat3< Type >::Mat3 ( const int8_t *  init_matrix)
inlineexplicit

Constructs a 3x3 matrix (copied from 9, 8 bit integers)

Member Function Documentation

template<typename Type>
Mat3< Type > uicore::Mat3< Type >::add ( const Mat3< Type > &  matrix_1,
const Mat3< Type > &  matrix_2 
)
inlinestatic

Add 2 matrices.

This adds the matrix as follows: result = matrix1 + matrix2

Parameters
matrix_1= First Matrix to add
matrix_2= Second Matrix to add
Returns
The matrix
template<typename Type>
Mat3< Type > uicore::Mat3< Type >::adjoint ( const Mat3< Type > &  matrix)
inlinestatic

Calculate the adjoint (or known as Adjugate or Conjugate Transpose) of a matrix.

Parameters
matrix= The matrix to use
Returns
The adjoint matrix
template<typename Type>
Mat3<Type>& uicore::Mat3< Type >::adjoint ( )

Creates the adjoint (or known as adjugate) of the matrix.

Returns
reference to this object
template<typename Type>
double uicore::Mat3< Type >::det ( ) const

Calculate the matrix determinant.

template<typename Type >
Mat3< Type > uicore::Mat3< Type >::identity ( )
inlinestatic

References uicore::m, and uicore::null.

template<typename Type>
Mat3< Type > uicore::Mat3< Type >::inverse ( const Mat3< Type > &  matrix)
inlinestatic

Calculate the matrix inverse of a matrix.

Creates a zero matrix if the determinent == 0

Parameters
matrix= The matrix to use
Returns
The inversed matrix
template<typename Type>
Mat3<Type>& uicore::Mat3< Type >::inverse ( )

Create the matrix inverse. (Returns a zero matrix if the determinent = 0)

Returns
reference to this object
template<typename Type>
static bool uicore::Mat3< Type >::is_equal ( const Mat3< Type > &  first,
const Mat3< Type > &  second,
Type  epsilon 
)
inlinestatic

Returns true if equal within the bounds of an epsilon.

Parameters
first= Value A
second= Value B
epsilon= The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2)

Referenced by uicore::Mat3< float >::is_equal().

template<typename Type>
bool uicore::Mat3< Type >::is_equal ( const Mat3< Type > &  other,
Type  epsilon 
) const
inline

Returns true if equal within the bounds of an epsilon.

Parameters
other= Other value
epsilon= The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2)
template<typename Type>
Mat3< Type > uicore::Mat3< Type >::multiply ( const Mat3< Type > &  matrix_1,
const Mat3< Type > &  matrix_2 
)
inlinestatic

Multiply 2 matrices.

This multiplies the matrix as follows: result = matrix1 * matrix2
Matrix is multiplied in the Column-Major matrix format (opengl native)

Parameters
matrix_1= First Matrix to multiply
matrix_2= Second Matrix to multiply
Returns
The matrix
template<typename Type >
Mat3< Type > uicore::Mat3< Type >::null ( )
inlinestatic

References uicore::m.

template<typename Type>
uicore::Mat3< Type >::operator Type * ( )
inline

Operator that returns the matrix as a array.

References uicore::Mat3< Type >::matrix.

template<typename Type>
uicore::Mat3< Type >::operator Type const * ( ) const
inline

Operator that returns the matrix as a array.

References uicore::Mat3< Type >::matrix.

template<typename Type>
bool uicore::Mat3< Type >::operator!= ( const Mat3< Type > &  other)
inline

Not-equal operator.

template<typename Type>
Mat3<Type> uicore::Mat3< Type >::operator* ( const Mat3< Type > &  mult) const

Multiplication operator.

template<typename Type>
Vec2<Type> uicore::Mat3< Type >::operator* ( const Vec2< Type > &  mult) const

Multiplication operator.

template<typename Type>
Mat3<Type> uicore::Mat3< Type >::operator+ ( const Mat3< Type > &  add_matrix) const

Addition operator.

template<typename Type>
Mat3<Type> uicore::Mat3< Type >::operator- ( const Mat3< Type > &  sub_matrix) const

Subtraction operator.

template<typename Type>
Mat3<Type>& uicore::Mat3< Type >::operator= ( const Mat3< Type > &  copy)
inline

Copy assignment operator.

template<typename Type>
Mat3<Type>& uicore::Mat3< Type >::operator= ( const Mat4< Type > &  copy)

Copy assignment operator.

template<typename Type>
Mat3<Type>& uicore::Mat3< Type >::operator= ( const Mat2< Type > &  copy)

Copy assignment operator.

template<typename Type>
bool uicore::Mat3< Type >::operator== ( const Mat3< Type > &  other) const
inline

Equality operator.

template<typename Type>
Type& uicore::Mat3< Type >::operator[] ( int  i)
inline

Operator that returns the matrix cell at the given index.

template<typename Type>
const Type& uicore::Mat3< Type >::operator[] ( int  i) const
inline

Operator that returns the matrix cell at the given index.

template<typename Type>
Type& uicore::Mat3< Type >::operator[] ( unsigned int  i)
inline

Operator that returns the matrix cell at the given index.

template<typename Type>
const Type& uicore::Mat3< Type >::operator[] ( unsigned int  i) const
inline

Operator that returns the matrix cell at the given index.

template<typename Type>
static Mat3<Type> uicore::Mat3< Type >::rotate ( Type  angle,
Type  x,
Type  y,
Type  z,
bool  normalize = true 
)
static

Create a 3d rotation matrix.

Matrix is created in the Column-Major matrix format (opengl native)

Parameters
angle= Angle to rotate by in radians
x= Amount to rotate in the X axis
y= Amount to rotate in the Y axis
z= Amount to rotate in the Z axis
normalize= true = Normalize x,y,z before creating rotation matrix
Returns
The matrix (in column-major format)

Referenced by uicore::Mat3< float >::rotate().

template<typename Type>
static Mat3<Type> uicore::Mat3< Type >::rotate ( float  angle,
Vec3< Type >  rotation,
bool  normalize = true 
)
inlinestatic

Create a 3d rotation matrix.

Matrix is created in the Column-Major matrix format (opengl native)

Parameters
angle= Angle to rotate by in radians
rotation= Amount to rotate in the XYZ axes
normalize= true = Normalize x,y,z before creating rotation matrix
Returns
The matrix (in column-major format)
template<typename Type>
static Mat3<Type> uicore::Mat3< Type >::rotate ( Type  angle_x,
Type  angle_y,
Type  angle_z,
EulerOrder  order 
)
static

Create a 3d rotation matrix using euler angles.

Matrix is created in the Column-Major matrix format (opengl native)

Returns
The matrix (in column-major format)
template<typename Type>
static Mat3<Type> uicore::Mat3< Type >::rotate ( Type  angle)
static

Create a 2d rotation matrix.

Matrix is created in the Column-Major matrix format (opengl native)

Parameters
angle= Angle to rotate by in radians
Returns
The matrix (in column-major format)
template<typename Type>
static Mat3<Type> uicore::Mat3< Type >::scale ( Type  x,
Type  y 
)
static

Create a 2d scale matrix.

Parameters
x= Scale X
y= Scale Y
Returns
The matrix

Referenced by uicore::Mat3< float >::scale().

template<typename Type>
static Mat3<Type> uicore::Mat3< Type >::scale ( const Vec3< Type > &  xy)
inlinestatic

Create a 2d scale matrix.

Parameters
xy= Scale XY
Returns
The matrix
template<typename Type>
Mat3< Type > uicore::Mat3< Type >::subtract ( const Mat3< Type > &  matrix_1,
const Mat3< Type > &  matrix_2 
)
inlinestatic

Subtract 2 matrices.

This subtracts the matrix as follows: result = matrix1 - matrix2

Parameters
matrix_1= First Matrix to subtract
matrix_2= Second Matrix to subtract
Returns
The matrix
template<typename Type>
static Mat3<Type> uicore::Mat3< Type >::translate ( Type  x,
Type  y 
)
static

Create a 2d translation matrix.

Matrix is created in the Column-Major matrix format (opengl native)

Parameters
x= Translate X
y= Translate Y
Returns
The matrix (in column-major format)

Referenced by uicore::Mat3< float >::translate().

template<typename Type>
static Mat3<Type> uicore::Mat3< Type >::translate ( const Vec2< Type > &  xy)
inlinestatic

Create a 2d translation matrix.

Matrix is created in the Column-Major matrix format (opengl native)

Parameters
xy= Translate XY
Returns
The matrix (in column-major format)
template<typename Type>
Mat3< Type > uicore::Mat3< Type >::transpose ( const Mat3< Type > &  matrix)
inlinestatic

Calculate the transpose of a matrix.

Parameters
matrix= The matrix to use
Returns
The transposed matrix
template<typename Type>
Mat3<Type>& uicore::Mat3< Type >::transpose ( )

Calculate the transpose of this matrix.

Returns
reference to this object

Member Data Documentation

template<typename Type>
Type uicore::Mat3< Type >::matrix[9]

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