clan::Mat3< Type > Class Template Reference - ClanLib SDK
Description: clan::Mat3< Type > Class Template Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clan::Mat3< Type > Class Template Reference
clanCore Math

3D matrix More...

`#include <mat3.h>`

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

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

## Public Attributes
Type | matrix [9]
| The matrix (in column-major format)

## Detailed Description

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

3D matrix

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

## Constructor & Destructor Documentation

## ◆ Mat3() [1/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( |  | ) |
| inline

Constructs a 3x3 matrix (zero'ed)

Referenced by add(), adjoint(), identity(), inverse(), multiply(), null(), subtract(), and transpose().

## ◆ Mat3() [2/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const Mat3< Type > & | copy | ) |
| default

Constructs a 3x3 matrix (copied)

## ◆ Mat3() [3/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const Mat2< Type > & | copy | ) |
| explicit

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

## ◆ Mat3() [4/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const Mat4< Type > & | copy | ) |
| explicit

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

## ◆ Mat3() [5/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const float * | init_matrix | ) |
| inlineexplicit

Constructs a 3x3 matrix (copied from 9 floats)

## ◆ Mat3() [6/11]

template<typename Type>

clan::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)

## ◆ Mat3() [7/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const double * | init_matrix | ) |
| inlineexplicit

Constructs a 3x3 matrix (copied from 9 doubles)

## ◆ Mat3() [8/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const int64_t * | init_matrix | ) |
| inlineexplicit

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

## ◆ Mat3() [9/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const int32_t * | init_matrix | ) |
| inlineexplicit

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

## ◆ Mat3() [10/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const int16_t * | init_matrix | ) |
| inlineexplicit

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

## ◆ Mat3() [11/11]

template<typename Type>

clan::Mat3< Type >::Mat3 | ( | const int8_t * | init_matrix | ) |
| inlineexplicit

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

## Member Function Documentation

## ◆ adjoint()

template<typename Type>

Mat3< Type > & clan::Mat3< Type >::adjoint | ( |  | ) |

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

Returns
  reference to this object

## ◆ det()

template<typename Type>

double clan::Mat3< Type >::det | ( |  | ) | const

Calculate the matrix determinant.

## ◆ inverse()

template<typename Type>

Mat3< Type > & clan::Mat3< Type >::inverse | ( |  | ) |

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

Returns
  reference to this object

## ◆ is_equal() [1/2]

template<typename Type>

bool clan::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 clan::Mat3< int >::is_equal().

## ◆ is_equal() [2/2]

template<typename Type>

bool clan::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)

## ◆ operator Type *()

template<typename Type>

clan::Mat3< Type >::operator Type * | ( |  | ) |
| inline

Operator that returns the matrix as a array.

## ◆ operator Type const *()

template<typename Type>

clan::Mat3< Type >::operator Type const * | ( |  | ) | const
| inline

Operator that returns the matrix as a array.

## ◆ operator!=()

template<typename Type>

bool clan::Mat3< Type >::operator!= | ( | const Mat3< Type > & | other | ) |
| inline

Not-equal operator.

## ◆ operator*() [1/2]

template<typename Type>

Mat3< Type > clan::Mat3< Type >::operator* | ( | const Mat3< Type > & | mult | ) | const

Multiplication operator.

## ◆ operator*() [2/2]

template<typename Type>

Vec2< Type > clan::Mat3< Type >::operator* | ( | const Vec2< Type > & | mult | ) | const

Multiplication operator.

## ◆ operator+()

template<typename Type>

Mat3< Type > clan::Mat3< Type >::operator+ | ( | const Mat3< Type > & | add_matrix | ) | const

Addition operator.

## ◆ operator-()

template<typename Type>

Mat3< Type > clan::Mat3< Type >::operator- | ( | const Mat3< Type > & | sub_matrix | ) | const

Subtraction operator.

## ◆ operator=() [1/3]

template<typename Type>

Mat3< Type > & clan::Mat3< Type >::operator= | ( | const Mat2< Type > & | copy | ) |

Copy assignment operator.

## ◆ operator=() [2/3]

template<typename Type>

Mat3< Type > & clan::Mat3< Type >::operator= | ( | const Mat3< Type > & | copy | ) |
| default

Copy assignment operator.

## ◆ operator=() [3/3]

template<typename Type>

Mat3< Type > & clan::Mat3< Type >::operator= | ( | const Mat4< Type > & | copy | ) |

Copy assignment operator.

## ◆ operator==()

template<typename Type>

bool clan::Mat3< Type >::operator== | ( | const Mat3< Type > & | other | ) | const
| inline

Equality operator.

## ◆ operator[]() [1/4]

template<typename Type>

Type & clan::Mat3< Type >::operator[] | ( | int | i | ) |
| inline

Operator that returns the matrix cell at the given index.

## ◆ operator[]() [2/4]

template<typename Type>

const Type & clan::Mat3< Type >::operator[] | ( | int | i | ) | const
| inline

Operator that returns the matrix cell at the given index.

## ◆ operator[]() [3/4]

template<typename Type>

Type & clan::Mat3< Type >::operator[] | ( | unsigned int | i | ) |
| inline

Operator that returns the matrix cell at the given index.

## ◆ operator[]() [4/4]

template<typename Type>

const Type & clan::Mat3< Type >::operator[] | ( | unsigned int | i | ) | const
| inline

Operator that returns the matrix cell at the given index.

## ◆ rotate() [1/4]

template<typename Type>

Mat3< Type > clan::Mat3< Type >::rotate | ( | const Angle & | angle | ) |
| static

Create a 2d rotation matrix.

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

Parameters

  angle | = Angle to rotate by

Returns
  The matrix (in column-major format)

## ◆ rotate() [2/4]

template<typename Type>

Mat3< Type > clan::Mat3< Type >::rotate | ( | const Angle & | 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
  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 clan::Mat3< int >::rotate().

## ◆ rotate() [3/4]

template<typename Type>

Mat3< Type > clan::Mat3< Type >::rotate | ( | const Angle & | 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
  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)

## ◆ rotate() [4/4]

template<typename Type>

Mat3< Type > clan::Mat3< Type >::rotate | ( | const Angle & | angle_x,
|  | const Angle & | angle_y,
|  | const Angle & | 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)

## ◆ scale() [1/2]

template<typename Type>

Mat3< Type > clan::Mat3< Type >::scale | ( | const Vec3< Type > & | xy | ) |
| inlinestatic

Create a 2d scale matrix.

Parameters

  xy | = Scale XY

Returns
  The matrix

## ◆ scale() [2/2]

template<typename Type>

Mat3< Type > clan::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 clan::Mat3< int >::scale().

## ◆ translate() [1/2]

template<typename Type>

Mat3< Type > clan::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)

## ◆ translate() [2/2]

template<typename Type>

Mat3< Type > clan::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 clan::Mat3< int >::translate().

## ◆ transpose()

template<typename Type>

Mat3< Type > & clan::Mat3< Type >::transpose | ( |  | ) |

Calculate the transpose of this matrix.

Returns
  reference to this object

## Member Data Documentation

## ◆ matrix

template<typename Type>

Type clan::Mat3< Type >::matrix[9]

The matrix (in column-major format)

Referenced by adjoint(), inverse(), clan::Mat3< int >::is_equal(), clan::Mat3< int >::operator==(), clan::ProgramObject::set_uniform_matrix(), clan::ProgramObject::set_uniform_matrix(), and transpose().

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

- mat2.h
- mat3.h