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

References clan::i, and clan::Mat3< Type >::matrix.

◆ Mat3() [2/11]

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

Constructs a 3x3 matrix (copied)

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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)

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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)

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

◆ Mat3() [7/11]

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

Constructs a 3x3 matrix (copied from 9 doubles)

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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)

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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)

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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)

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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)

References clan::i, and clan::Mat3< Type >::matrix.

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 >
static 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)

References clan::i, and clan::Mat3< Type >::matrix.

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

References clan::Mat3< Type >::is_equal().

◆ 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)
inline

Copy assignment operator.

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

◆ 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.

References clan::i, and clan::Mat3< Type >::matrix.

◆ operator[]() [1/4]

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

Operator that returns the matrix cell at the given index.

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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.

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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.

References clan::i, and clan::Mat3< Type >::matrix.

◆ 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.

References clan::i, and clan::Mat3< Type >::matrix.

◆ rotate() [1/4]

template<typename Type >
static 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 >
static 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< Type >::rotate().

◆ rotate() [3/4]

template<typename Type >
static 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)

References clan::angle, clan::Mat3< Type >::rotate(), clan::Vec3< Type >::x, clan::Vec3< Type >::y, and clan::Vec3< Type >::z.

◆ rotate() [4/4]

template<typename Type >
static 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 >
static Mat3< Type > clan::Mat3< Type >::scale ( const Vec3< Type > & xy)
inlinestatic

Create a 2d scale matrix.

Parameters
xy= Scale XY
Returns
The matrix

References clan::Mat3< Type >::scale(), clan::Vec3< Type >::x, and clan::Vec3< Type >::y.

◆ scale() [2/2]

template<typename Type >
static 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< Type >::scale().

◆ translate() [1/2]

template<typename Type >
static 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)

References clan::Mat3< Type >::translate(), clan::Vec2< Type >::x, and clan::Vec2< Type >::y.

◆ translate() [2/2]

template<typename Type >
static 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< Type >::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


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