NGL  6.5
The NCCA Graphics Library
ngl::Mat3 Class Reference

Mat3 basic 3x3 matrix for certain glsl ops. More...

#include <Mat3.h>

+ Collaboration diagram for ngl::Mat3:

Public Member Functions

 Mat3 () noexcept
 ctor will always create an identity matrix More...
 
 Mat3 (Real _00, Real _01, Real _02, Real _10, Real _11, Real _12, Real _20, Real _21, Real _22) noexcept
 ctor passing in value More...
 
 Mat3 (const Mat4 &_m) noexcept
 copy ctor from mat4 will copy left up and fwd vectors More...
 
 Mat3 (const Mat3 &_m) noexcept
 copy ctor with reference object More...
 
 Mat3 (const Real _m) noexcept
 copy ctor with Real useful for Matrix m=1; for identity or Matrix m=3.5 for uniform scale More...
 
void setAtXY (GLint _x, GLint _y, Real _equals) noexcept
 set the value at m_m[_x][_y] to _equals More...
 
const Mat3null () noexcept
 clear the matrix to all 0 More...
 
const Mat3identity () noexcept
 make the matrix m the identity matrix
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
More...
 
Mat3 operator* (const Mat3 &_m) const noexcept
 operator for matrix multiplication More...
 
const Mat3operator*= (const Mat3 &_m) noexcept
 operator to mult this matrix by value _m More...
 
Mat3 operator+ (const Mat3 &_m) const noexcept
 operator to add two matrices together More...
 
const Mat3operator+= (const Mat3 &_m) noexcept
 += operator More...
 
Mat3 operator* (Real _i) const noexcept
 operator to mult matrix by a scalar More...
 
const Mat3operator*= (Real _i) noexcept
 *= operator with a scalar value More...
 
Vec3 operator* (const Vec3 &_v) const noexcept
 multiply this by a Vec3 More...
 
const Mat3transpose () noexcept
 method to transpose the matrix More...
 
void rotateX (Real _deg) noexcept
 set this matrix to a rotation matrix in the X axis for value _deg note the matrix should be set to identity before doing this More...
 
void rotateY (Real _deg) noexcept
 set this matrix to a rotation matrix in the Y axis for value _deg note the matrix should be set to identity before doing this More...
 
void rotateZ (Real _deg) noexcept
 set this matrix to a rotation matrix in the Z axis for value _deg note the matrix should be set to identity before doing this More...
 
void scale (Real _x, Real _y, Real _z) noexcept
 set the matrix scale values More...
 
Real determinant () const noexcept
 get the determinant of the matrix More...
 
Mat3 inverse () noexcept
 set the matrix to be the inverse More...
 
void euler (Real _angle, Real _x, Real _y, Real _z) noexcept
 axis / angle rotation using the Euler method More...
 
RealopenGL () noexcept
 accesor to the openGL matrix More...
 
Vec3 getLeftVector () const noexcept
 get the left vector of the matrix (-ve 1st Row) More...
 
Vec3 getRightVector () const noexcept
 get the right vector of the matrix ( 1nd Row) More...
 
Vec3 getUpVector () const noexcept
 get the up vector of the matrix (2nd Row) More...
 
Vec3 getDownVector () const noexcept
 get the down vector of the matrix ( -ve 2nd Row) More...
 
Vec3 getForwardVector () const noexcept
 get the forward vector of the matrix (-ve 3rd Row) More...
 
Vec3 getBackVector () const noexcept
 get the back vector of the matrix ( 3nd Row) More...
 

Public Attributes

Real m_m [3][3]
 Mat3 element m_m as a 4x4 array mapped by union to m_nn elements and m_openGL. More...
 
std::array< Real, 9 > m_openGL
 The matrix in m_openGL 16 Real array format usefull for OpenGL fv formats mapped to m_m[][] elements and m_xx elements. More...
 
Real m_00
 individual matrix element maps to m_m[0][0] or m_openGL[0] More...
 
Real m_01
 individual matrix element maps to m_m[0][1] or m_openGL[1] More...
 
Real m_02
 individual matrix element maps to m_m[0][2] or m_openGL[2] More...
 
Real m_10
 individual matrix element maps to m_m[1][0] or m_openGL[4] More...
 
Real m_11
 individual matrix element maps to m_m[1][1] or m_openGL[5] More...
 
Real m_12
 individual matrix element maps to m_m[1][2] or m_openGL[6] More...
 
Real m_20
 individual matrix element maps to m_m[2][0] or m_openGL[8] More...
 
Real m_21
 individual matrix element maps to m_m[2][1] or m_openGL[9] More...
 
Real m_22
 individual matrix element maps to m_m[2][2] or m_openGL[10] More...
 

Friends

class Transformation
 
class Quaternion
 
class Camera
 

Detailed Description

Mat3 basic 3x3 matrix for certain glsl ops.

Author
Jonathan Macey
Version
1.0
Date
27/10/11

Definition at line 43 of file Mat3.h.

Constructor & Destructor Documentation

ngl::Mat3::Mat3 ( )
noexcept

ctor will always create an identity matrix

Definition at line 36 of file Mat3.cpp.

References m_00, m_11, m_22, and m_m.

+ Here is the caller graph for this function:

ngl::Mat3::Mat3 ( Real  _00,
Real  _01,
Real  _02,
Real  _10,
Real  _11,
Real  _12,
Real  _20,
Real  _21,
Real  _22 
)
noexcept

ctor passing in value

Definition at line 57 of file Mat3.cpp.

References m_00, m_01, m_02, m_10, m_11, m_12, m_20, m_21, and m_22.

ngl::Mat3::Mat3 ( const Mat4 _m)
noexcept

copy ctor from mat4 will copy left up and fwd vectors

Definition at line 44 of file Mat3.cpp.

References m_00, m_01, m_02, m_10, m_11, m_12, m_20, m_21, and m_22.

ngl::Mat3::Mat3 ( const Mat3 _m)
noexcept

copy ctor with reference object

Definition at line 72 of file Mat3.cpp.

References m_m.

ngl::Mat3::Mat3 ( const Real  _m)
noexcept

copy ctor with Real useful for Matrix m=1; for identity or Matrix m=3.5 for uniform scale

Definition at line 80 of file Mat3.cpp.

References m_00, m_11, m_22, and m_m.

Member Function Documentation

Real ngl::Mat3::determinant ( ) const
noexcept

get the determinant of the matrix

Returns
the determinat

Definition at line 338 of file Mat3.cpp.

References m_00, m_01, m_02, m_10, m_11, m_12, m_20, m_21, and m_22.

+ Here is the caller graph for this function:

void ngl::Mat3::euler ( Real  _angle,
Real  _x,
Real  _y,
Real  _z 
)
noexcept

axis / angle rotation using the Euler method

Parameters
[in]_anglethe angle in degree to rotate
[in]_xpart of the axis should be normalised before call
[in]_ypart of the axis should be normalised before call
[in]_zpart of the axis should be normalised before call

Definition at line 320 of file Mat3.cpp.

References m_m, and ngl::radians().

+ Here is the call graph for this function:

Vec3 ngl::Mat3::getBackVector ( ) const
noexcept

get the back vector of the matrix ( 3nd Row)

Returns
the up vector

Definition at line 404 of file Mat3.cpp.

References m_openGL.

Vec3 ngl::Mat3::getDownVector ( ) const
noexcept

get the down vector of the matrix ( -ve 2nd Row)

Returns
the up vector

Definition at line 392 of file Mat3.cpp.

References m_openGL.

Vec3 ngl::Mat3::getForwardVector ( ) const
noexcept

get the forward vector of the matrix (-ve 3rd Row)

Returns
the up vector

Definition at line 398 of file Mat3.cpp.

References m_openGL.

Vec3 ngl::Mat3::getLeftVector ( ) const
noexcept

get the left vector of the matrix (-ve 1st Row)

Returns
the up vector

Definition at line 374 of file Mat3.cpp.

References m_openGL.

Vec3 ngl::Mat3::getRightVector ( ) const
noexcept

get the right vector of the matrix ( 1nd Row)

Returns
the up vector

Definition at line 379 of file Mat3.cpp.

References m_openGL.

Vec3 ngl::Mat3::getUpVector ( ) const
noexcept

get the up vector of the matrix (2nd Row)

Returns
the up vector

Definition at line 385 of file Mat3.cpp.

References m_openGL.

const Mat3 & ngl::Mat3::identity ( )
noexcept

make the matrix m the identity matrix
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

Definition at line 105 of file Mat3.cpp.

References m_00, m_11, m_22, and m_m.

Mat3 ngl::Mat3::inverse ( )
noexcept

set the matrix to be the inverse

Definition at line 346 of file Mat3.cpp.

References determinant(), m_00, m_01, m_02, m_10, m_11, m_12, m_20, m_21, m_22, and Mat3().

+ Here is the call graph for this function:

const Mat3 & ngl::Mat3::null ( )
noexcept

clear the matrix to all 0

Definition at line 99 of file Mat3.cpp.

References m_m.

Real* ngl::Mat3::openGL ( )
inlinenoexcept

accesor to the openGL matrix

Returns
a pointer to m_openGL[0]

Definition at line 188 of file Mat3.h.

Mat3 ngl::Mat3::operator* ( const Mat3 _m) const
noexcept

operator for matrix multiplication

Parameters
[in]_mthe matrix to multiply the current one by
Returns
this*_m

Definition at line 115 of file Mat3.cpp.

References m_m.

Mat3 ngl::Mat3::operator* ( Real  _i) const
noexcept

operator to mult matrix by a scalar

Parameters
[in]_ithe scalar to multiply by
Returns
this*_i

Definition at line 210 of file Mat3.cpp.

References m_openGL.

Vec3 ngl::Mat3::operator* ( const Vec3 _v) const
noexcept

multiply this by a Vec3

Parameters
[in]_vthe vector to multiply
Returns
Vector M*V

Definition at line 304 of file Mat3.cpp.

References m_00, m_01, m_02, m_10, m_11, m_12, m_20, m_21, m_22, ngl::Vec3::m_x, ngl::Vec3::m_y, and ngl::Vec3::m_z.

const Mat3 & ngl::Mat3::operator*= ( const Mat3 _m)
noexcept

operator to mult this matrix by value _m

Parameters
[in]_mthe matrix to multiplt
Returns
a new matrix this*_m

Definition at line 132 of file Mat3.cpp.

References m_00, m_01, m_02, m_10, m_11, m_12, m_20, m_21, and m_22.

const Mat3 & ngl::Mat3::operator*= ( Real  _i)
noexcept

*= operator with a scalar value

Parameters
[in]_ithe scalar to multiply by
Returns
the matrix*i

Definition at line 225 of file Mat3.cpp.

References m_m.

Mat3 ngl::Mat3::operator+ ( const Mat3 _m) const
noexcept

operator to add two matrices together

Parameters
[in]_mthe matrix to add
Returns
this+_m

Definition at line 182 of file Mat3.cpp.

References m_openGL.

const Mat3 & ngl::Mat3::operator+= ( const Mat3 _m)
noexcept

+= operator

Parameters
[in]_mthe matrix to add
Returns
this+m

Definition at line 197 of file Mat3.cpp.

References m_openGL.

void ngl::Mat3::rotateX ( Real  _deg)
noexcept

set this matrix to a rotation matrix in the X axis for value _deg note the matrix should be set to identity before doing this

Parameters
[in]_degthe value to be rotated by in degrees

Definition at line 258 of file Mat3.cpp.

References m_11, m_12, m_21, m_22, and ngl::radians().

+ Here is the call graph for this function:

void ngl::Mat3::rotateY ( Real  _deg)
noexcept

set this matrix to a rotation matrix in the Y axis for value _deg note the matrix should be set to identity before doing this

Parameters
[in]_degthe value to be rotated by in degrees

Definition at line 270 of file Mat3.cpp.

References m_00, m_02, m_20, m_22, and ngl::radians().

+ Here is the call graph for this function:

void ngl::Mat3::rotateZ ( Real  _deg)
noexcept

set this matrix to a rotation matrix in the Z axis for value _deg note the matrix should be set to identity before doing this

Parameters
[in]_degthe value to be rotated by in degrees

Definition at line 282 of file Mat3.cpp.

References m_00, m_01, m_10, m_11, and ngl::radians().

+ Here is the call graph for this function:

void ngl::Mat3::scale ( Real  _x,
Real  _y,
Real  _z 
)
noexcept

set the matrix scale values

Parameters
[in]_xthe scale value in the _x
[in]_ythe scale value in the _y
[in]_zthe scale value in the _z

Definition at line 296 of file Mat3.cpp.

References m_00, m_11, and m_22.

void ngl::Mat3::setAtXY ( GLint  _x,
GLint  _y,
Real  _equals 
)
noexcept

set the value at m_m[_x][_y] to _equals

Parameters
[in]_xthe x index into the array
[in]_ythe y index into the array
[in]_equalsthe value to set to
Todo:
replace this with function operator overload ()

Definition at line 94 of file Mat3.cpp.

References m_m.

const Mat3 & ngl::Mat3::transpose ( )
noexcept

method to transpose the matrix

Definition at line 241 of file Mat3.cpp.

References m_m.

Friends And Related Function Documentation

friend class Camera
friend

Definition at line 225 of file Mat3.h.

friend class Quaternion
friend

Definition at line 224 of file Mat3.h.

friend class Transformation
friend

Definition at line 223 of file Mat3.h.

Member Data Documentation

Real ngl::Mat3::m_00

individual matrix element maps to m_m[0][0] or m_openGL[0]

Definition at line 256 of file Mat3.h.

Real ngl::Mat3::m_01

individual matrix element maps to m_m[0][1] or m_openGL[1]

Definition at line 260 of file Mat3.h.

Real ngl::Mat3::m_02

individual matrix element maps to m_m[0][2] or m_openGL[2]

Definition at line 264 of file Mat3.h.

Real ngl::Mat3::m_10

individual matrix element maps to m_m[1][0] or m_openGL[4]

Definition at line 268 of file Mat3.h.

Real ngl::Mat3::m_11

individual matrix element maps to m_m[1][1] or m_openGL[5]

Definition at line 272 of file Mat3.h.

Real ngl::Mat3::m_12

individual matrix element maps to m_m[1][2] or m_openGL[6]

Definition at line 276 of file Mat3.h.

Real ngl::Mat3::m_20

individual matrix element maps to m_m[2][0] or m_openGL[8]

Definition at line 280 of file Mat3.h.

Real ngl::Mat3::m_21

individual matrix element maps to m_m[2][1] or m_openGL[9]

Definition at line 284 of file Mat3.h.

Real ngl::Mat3::m_22

individual matrix element maps to m_m[2][2] or m_openGL[10]

Definition at line 288 of file Mat3.h.

Real ngl::Mat3::m_m[3][3]

Mat3 element m_m as a 4x4 array mapped by union to m_nn elements and m_openGL.

Definition at line 237 of file Mat3.h.

std::array<Real,9> ngl::Mat3::m_openGL
Initial value:
={{
1.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,
0.0f,0.0f,1.0f
}}

The matrix in m_openGL 16 Real array format usefull for OpenGL fv formats mapped to m_m[][] elements and m_xx elements.

Definition at line 243 of file Mat3.h.


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