Drag[en]gine Game Engine  1.21
decMatrix Class Reference

4x4 Component Matrix. Provides matrix calculation on a 4x4 matrix in row major order. The coordinate system used by axis oriented creation functions is a left handed one. The X axis points to the right, the Y axis points up and the Z axis points into the screen. Rotations are always in counter clockwise orientation. Rotation angles are measured in radians. More...

#include <decMatrix.h>

Public Member Functions

Constructors and Destructors
 decMatrix ()
 Create new matrix initialized to identity. More...
 
 decMatrix (const decMatrix &m)
 Create copy of a matrix. More...
 
 decMatrix (const decDMatrix &m)
 Create copy of a double matrix. More...
 
Management
void SetIdentity ()
 Sets identity matrix. More...
 
void SetTranslation (float x, float y, float z)
 Sets translation matrix. More...
 
void SetTranslation (const decVector &t)
 Sets translation matrix. More...
 
void SetScale (float sx, float sy, float sz)
 Sets scaling matrix. More...
 
void SetScale (const decVector &s)
 Sets scaling matrix. More...
 
void SetRotationX (float arc)
 Sets rotation around the x axis matrix. More...
 
void SetRotationY (float arc)
 Sets rotation around the y axis matrix. More...
 
void SetRotationZ (float arc)
 Sets rotation around the z axis matrix. More...
 
void SetRotation (float rx, float ry, float rz)
 Set rotation around the all three axes matrix. More...
 
void SetRotation (const decVector &r)
 Set rotation around the all three axes matrix. More...
 
void SetRotationAxis (const decVector &axis, float angle)
 Sets rotation around an arbitrary axis matrix. More...
 
void SetWorld (const decVector &pos, const decVector &view, const decVector &up)
 Set world space matrix. More...
 
void SetWorld (const decVector &pos, const decQuaternion &orientation)
 Set world space matrix. More...
 
void SetWorld (const decVector &pos, const decQuaternion &orientation, const decVector &scale)
 Set world space matrix. More...
 
void SetCamera (const decVector &pos, const decVector &view, const decVector &up)
 Set camera space matrix. More...
 
void SetProjection (int width, int height, float fov, float fovRatio, float znear, float zfar)
 Set projection matrix based on a finite view frustum. More...
 
void SetProjectionInfinite (int width, int height, float fov, float fovRatio, float znear)
 Set projection matrix based on a infinite view frustum. More...
 
void SetOrtho (int left, int right, int top, int bottom, int znear, int zfar)
 Set orthogonal projection matrix. More...
 
void SetClipSpace ()
 Set matrix to transform a projection matrix into cliping space. More...
 
void SetBiasMatrix ()
 Set bias matrix which multiplies all coordinates by 0.5 and offsets them by 0.5. More...
 
void SetRT (const decVector &rot, const decVector &pos)
 Set rotation-translation matrix. More...
 
void SetSRT (const decVector &scale, const decVector &rot, const decVector &pos)
 Set scale-rotation-translation matrix. More...
 
void SetSVUT (const decVector &scale, const decVector &view, const decVector &up, const decVector &pos)
 Set scale-view-up-translation matrix. More...
 
void SetVU (const decVector &view, const decVector &up)
 Set view-up matrix. More...
 
void SetFromQuaternion (const decQuaternion &q)
 Set rotation matrix from a quaternion. More...
 
void SetFromQuaternion (const decQuaternion &q, const decVector &pivot)
 Set rotation matrix from a quaternion. More...
 
float Determinant () const
 Calculates the determinant of the matrix. More...
 
decMatrix Invert () const
 Inverse of this matrix if the inverse is possible. More...
 
decVector GetEulerAngles () const
 Calculate set of euler angles producing this matrix if they are used as rotation vector for creating a rotation matrix. More...
 
decQuaternion ToQuaternion () const
 Convert matrix into a rotation quaternion. More...
 
decVector GetPosition () const
 Position of the matrix. More...
 
decVector GetScale () const
 Scaling of the matrix. More...
 
decVector TransformView () const
 View vector of this matrix. More...
 
decVector TransformRight () const
 Right vector of this matrix. More...
 
decVector TransformUp () const
 Up vector of this matrix. More...
 
decVector TransformNormal (const decVector &normal) const
 Transforms a normal by this matrix. More...
 
decVector Transform (float x, float y, float z) const
 Transforma vector. More...
 
decVector4 Transform (float x, float y, float z, float w) const
 Transforma vector. More...
 
void Transform (decVector &result, float x, float y, float z) const
 Transforma vector. More...
 
void Transform (decVector4 &result, float x, float y, float z, float w) const
 Transforma vector. More...
 
decMatrix GetRotationMatrix () const
 Rotation part of the matrix. More...
 
void Normalize ()
 Normalize matrix. More...
 
decMatrix Normalized () const
 Normalize matrix. More...
 
bool IsEqualTo (const decMatrix &matrix, float threshold=0.0001) const
 Matrix is cell wise equal to anither one in respect to a threshold. More...
 
Quick Calculations

Quick calculations are a special set of functions designed to work only with matrices which are non-projective. This kind of matrices have only a rotation part and a translation part. The entire last row has the values 0,0,0,1 . Those functions are the same as the non-quick versions with the difference that calculations are stripped out due to the last row beeing 0,0,0,1 . As the name suggests those functions are faster than the normal ones for projective matrices due to them having less calculations. Only use those functions if you know for sure that your matrices are of the described kind.

decMatrix QuickMultiply (const decMatrix &matrix) const
 Quick multiplies this matrix with another one. More...
 
decMatrix QuickMultiplyRotation (const decMatrix &matrix) const
 Quick multiplies this matrix rotation part with another one. More...
 
decMatrix QuickMultiply (float k) const
 Quick multiplies this matrix with a value k. More...
 
float QuickDeterminant () const
 Quick calculates the determinant of this matrix. More...
 
decMatrix QuickInvert () const
 Quick calculates the inverse of this matrix. More...
 
decMatrixQuickAddTo (const decMatrix &m)
 Quick cell wise adds another matrix to this matrix. More...
 
Operators
decMatrixoperator= (const decMatrix &m)
 Set cells of this matrix to the values of another one. More...
 
decMatrixoperator+= (const decMatrix &m)
 Adds the cells of another matrix to this one. More...
 
decMatrixoperator-= (const decMatrix &m)
 Subtracts the cells of another matrix from this vector. More...
 
decMatrixoperator*= (float k)
 Multiplies the cells of this matrix with a value k. More...
 
decMatrixoperator/= (float k)
 Divide cells of this matrix by a value k. More...
 
decMatrixoperator*= (const decMatrix &m)
 Multiplies this matrix with another one. More...
 
decMatrix operator+ (const decMatrix &m) const
 Retrieves a new matrix with the sum of this matrix with another one. More...
 
decMatrix operator- (const decMatrix &m) const
 Retrieves a new matrix with the difference of this matrix to another one. More...
 
decMatrix operator* (float k) const
 Retrieves a new matrix with this matrix scaled by k. More...
 
decMatrix operator/ (float k) const
 Matrix with this matrix divided by k. More...
 
decMatrix operator* (const decMatrix &m) const
 Retrieves a new matrix with this matrix multiplied with another one. More...
 
decVector operator* (const decVector &v) const
 Transforms vector by this matrix. More...
 
decVector4 operator* (const decVector4 &v) const
 Transforms 4 component vector by this matrix. More...
 

Static Public Member Functions

Matrix Creation
static decMatrix CreateIdentity ()
 Create new identity matrix. More...
 
static decMatrix CreateTranslation (float x, float y, float z)
 Create new translation matrix. More...
 
static decMatrix CreateTranslation (const decVector &t)
 Create new translation matrix. More...
 
static decMatrix CreateScale (float sx, float sy, float sz)
 Create new scaling matrix. More...
 
static decMatrix CreateScale (const decVector &s)
 Create new scaling matrix. More...
 
static decMatrix CreateRotationX (float arc)
 Create new rotation around the x axis matrix. More...
 
static decMatrix CreateRotationY (float arc)
 Create new rotation around the y axis matrix. More...
 
static decMatrix CreateRotationZ (float arc)
 Create new rotation around the z axis matrix. More...
 
static decMatrix CreateRotation (float rx, float ry, float rz)
 Create new rotation around the all three axes matrix. More...
 
static decMatrix CreateRotation (const decVector &r)
 Create new rotation around the all three axes matrix. More...
 
static decMatrix CreateRotationAxis (const decVector &axis, float angle)
 Create new rotation around an arbitrary axis matrix. More...
 
static decMatrix CreateWorld (const decVector &pos, const decVector &view, const decVector &up)
 Create new world space matrix. More...
 
static decMatrix CreateWorld (const decVector &pos, const decQuaternion &orientation)
 Create new world space matrix. More...
 
static decMatrix CreateWorld (const decVector &pos, const decQuaternion &orientation, const decVector &scale)
 Create world space matrix. More...
 
static decMatrix CreateCamera (const decVector &pos, const decVector &view, const decVector &up)
 Create new camera space matrix. More...
 
static decMatrix CreateProjection (int width, int height, float fov, float fovRatio, float znear, float zfar)
 Create projection matrix based on a finite view frustum. More...
 
static decMatrix CreateProjectionInfinite (int width, int height, float fov, float fovRatio, float znear)
 Create projection matrix based on a infinite view frustum. More...
 
static decMatrix CreateOrtho (int left, int right, int top, int bottom, int znear, int zfar)
 Create orthogonal projection matrix. More...
 
static decMatrix CreateClipSpace ()
 Create matrix to transform a projection matrix into cliping space. More...
 
static decMatrix CreateBiasMatrix ()
 Create bias matrix which multiplies all coordinates by 0.5 and offsets them by 0.5. More...
 
static decMatrix CreateRT (const decVector &rot, const decVector &pos)
 Create rotation-translation matrix. More...
 
static decMatrix CreateSRT (const decVector &scale, const decVector &rot, const decVector &pos)
 Create scale-rotation-translation matrix. More...
 
static decMatrix CreateSVUT (const decVector &scale, const decVector &view, const decVector &up, const decVector &pos)
 Create scale-view-up-translation matrix. More...
 
static decMatrix CreateVU (const decVector &view, const decVector &up)
 Create view-up matrix. More...
 
static decMatrix CreateFromQuaternion (const decQuaternion &q)
 Create rotation matrix from a quaternion. More...
 
static decMatrix CreateFromQuaternion (const decQuaternion &q, const decVector &pivot)
 Create rotation matrix from a quaternion. More...
 

Public Attributes

Cells

The first number indicates the row the second the column.

float a11
 
float a12
 
float a13
 
float a14
 
float a21
 
float a22
 
float a23
 
float a24
 
float a31
 
float a32
 
float a33
 
float a34
 
float a41
 
float a42
 
float a43
 
float a44
 

Detailed Description

4x4 Component Matrix. Provides matrix calculation on a 4x4 matrix in row major order. The coordinate system used by axis oriented creation functions is a left handed one. The X axis points to the right, the Y axis points up and the Z axis points into the screen. Rotations are always in counter clockwise orientation. Rotation angles are measured in radians.

Constructor & Destructor Documentation

◆ decMatrix() [1/3]

decMatrix::decMatrix ( )

Create new matrix initialized to identity.

◆ decMatrix() [2/3]

decMatrix::decMatrix ( const decMatrix m)

Create copy of a matrix.

◆ decMatrix() [3/3]

decMatrix::decMatrix ( const decDMatrix m)

Create copy of a double matrix.

Member Function Documentation

◆ CreateBiasMatrix()

static decMatrix decMatrix::CreateBiasMatrix ( )
static

Create bias matrix which multiplies all coordinates by 0.5 and offsets them by 0.5.

◆ CreateCamera()

static decMatrix decMatrix::CreateCamera ( const decVector pos,
const decVector view,
const decVector up 
)
static

Create new camera space matrix.

A camera space matrix is different from a world space matrix in that it does transform positions from an world coordinate system into a coordinate system where the x axis points right, the y axis up and the z-axis straight into the screen. Best example to understand is a rotation. A world space matrix rotates a vector pointing straight down the z axis into the view vector used to create the matrix. A camera matrix though transforms a vector pointing into the view direction of the camera matrix into a vector pointing straight down the z axis. Hence the camera matrix is kinda the inverse of the world matrix what goes for the final transformation.

Parameters
posPosition of camera
viewView vector of camera not necessary normalized
upUp vector of camera not necessary normalized

◆ CreateClipSpace()

static decMatrix decMatrix::CreateClipSpace ( )
static

Create matrix to transform a projection matrix into cliping space.

In cliping space the view frustum turns into a cube.

◆ CreateFromQuaternion() [1/2]

static decMatrix decMatrix::CreateFromQuaternion ( const decQuaternion q)
static

Create rotation matrix from a quaternion.

Parameters
qRotation quaternion

◆ CreateFromQuaternion() [2/2]

static decMatrix decMatrix::CreateFromQuaternion ( const decQuaternion q,
const decVector pivot 
)
static

Create rotation matrix from a quaternion.

◆ CreateIdentity()

static decMatrix decMatrix::CreateIdentity ( )
static

Create new identity matrix.

◆ CreateOrtho()

static decMatrix decMatrix::CreateOrtho ( int  left,
int  right,
int  top,
int  bottom,
int  znear,
int  zfar 
)
static

Create orthogonal projection matrix.

Parameters
leftLeft cliping plane position
rightRight cliping plane position
topTop cliping plane position
bottomBottom cliping plane position
znearDistance to near cliping plane
zfarDistance to far cliping plane

◆ CreateProjection()

static decMatrix decMatrix::CreateProjection ( int  width,
int  height,
float  fov,
float  fovRatio,
float  znear,
float  zfar 
)
static

Create projection matrix based on a finite view frustum.

The width and height are used to derive the aspect ratio from.

Parameters
widthWidth of the viewport window
heightHeight of the viewport window
fovVertical field of view of the projection. Indicates the radian angle from the left side of the view frustum to the right side
fovRatioAspect ratio of the horizontal to the vertical field of view.
znearDistance to near cliping plane
zfarDistance to far cliping plane

◆ CreateProjectionInfinite()

static decMatrix decMatrix::CreateProjectionInfinite ( int  width,
int  height,
float  fov,
float  fovRatio,
float  znear 
)
static

Create projection matrix based on a infinite view frustum.

The width and height are used to derive the aspect ratio from.

Parameters
widthWidth of the viewport window
heightHeight of the viewport window
fovVertical field of view of the projection. Indicates the radian angle from the left side of the view frustum to the right side
fovRatioAspect ratio of the horizontal to the vertical field of view.
znearDistance to near cliping plane

◆ CreateRotation() [1/2]

static decMatrix decMatrix::CreateRotation ( const decVector r)
static

Create new rotation around the all three axes matrix.

This matrix is the same as first applying a z axis roation, then an x axis rotation and then an y axis rotation.

◆ CreateRotation() [2/2]

static decMatrix decMatrix::CreateRotation ( float  rx,
float  ry,
float  rz 
)
static

Create new rotation around the all three axes matrix.

This matrix is the same as first applying a z axis roation, then an x axis rotation and then an y axis rotation.

◆ CreateRotationAxis()

static decMatrix decMatrix::CreateRotationAxis ( const decVector axis,
float  angle 
)
static

Create new rotation around an arbitrary axis matrix.

◆ CreateRotationX()

static decMatrix decMatrix::CreateRotationX ( float  arc)
static

Create new rotation around the x axis matrix.

◆ CreateRotationY()

static decMatrix decMatrix::CreateRotationY ( float  arc)
static

Create new rotation around the y axis matrix.

◆ CreateRotationZ()

static decMatrix decMatrix::CreateRotationZ ( float  arc)
static

Create new rotation around the z axis matrix.

◆ CreateRT()

static decMatrix decMatrix::CreateRT ( const decVector rot,
const decVector pos 
)
static

Create rotation-translation matrix.

This is the same as first doing a 3-axis rotation and then a translation.

Parameters
rotRotation vector
posTranslation vector

◆ CreateScale() [1/2]

static decMatrix decMatrix::CreateScale ( const decVector s)
static

Create new scaling matrix.

◆ CreateScale() [2/2]

static decMatrix decMatrix::CreateScale ( float  sx,
float  sy,
float  sz 
)
static

Create new scaling matrix.

◆ CreateSRT()

static decMatrix decMatrix::CreateSRT ( const decVector scale,
const decVector rot,
const decVector pos 
)
static

Create scale-rotation-translation matrix.

This is the same as first doing a scaling, then a 3-axis rotation and then a translation.

Parameters
scaleScaling vector
rotRotation vector
posTranslation vector

◆ CreateSVUT()

static decMatrix decMatrix::CreateSVUT ( const decVector scale,
const decVector view,
const decVector up,
const decVector pos 
)
static

Create scale-view-up-translation matrix.

This is the same as first doing a scaling, then a world space matrix.

Parameters
scaleScaling vector
viewView vector
upUp vector
posTranslation vector

◆ CreateTranslation() [1/2]

static decMatrix decMatrix::CreateTranslation ( const decVector t)
static

Create new translation matrix.

◆ CreateTranslation() [2/2]

static decMatrix decMatrix::CreateTranslation ( float  x,
float  y,
float  z 
)
static

Create new translation matrix.

◆ CreateVU()

static decMatrix decMatrix::CreateVU ( const decVector view,
const decVector up 
)
static

Create view-up matrix.

This is the same as doing a world space matrix but with the zero vector as position.

Parameters
viewView vector
upUp vector

◆ CreateWorld() [1/3]

static decMatrix decMatrix::CreateWorld ( const decVector pos,
const decQuaternion orientation 
)
static

Create new world space matrix.

A world matrix is used to transform coordinates from the coordinate system of one object to another one.

Parameters
posPosition of object
orientationOrientation

◆ CreateWorld() [2/3]

static decMatrix decMatrix::CreateWorld ( const decVector pos,
const decQuaternion orientation,
const decVector scale 
)
static

Create world space matrix.

A world matrix is used to transform coordinates from the object local coordinate system to the world coordinate system.

◆ CreateWorld() [3/3]

static decMatrix decMatrix::CreateWorld ( const decVector pos,
const decVector view,
const decVector up 
)
static

Create new world space matrix.

A world matrix is used to transform coordinates from the coordinate system of one object to another one.

Parameters
posPosition of object
viewView vector of object not necessary normalized
upUp vector of object not necessary normalized

◆ Determinant()

float decMatrix::Determinant ( ) const

Calculates the determinant of the matrix.

◆ GetEulerAngles()

decVector decMatrix::GetEulerAngles ( ) const

Calculate set of euler angles producing this matrix if they are used as rotation vector for creating a rotation matrix.

The calculated angles are not unique and different rotation vectors lead usually to the same matrix. The calculated rotation vector is garanteed to produce the matrix it has been calculated from. Furthermore there exist ambiguous situations where the calculated rotation vector is undefined. You should avoid using this function if you can.

◆ GetPosition()

decVector decMatrix::GetPosition ( ) const

Position of the matrix.

This is the same as transforming the vector ( 0,0,0 ) by this matrix but faster.

◆ GetRotationMatrix()

decMatrix decMatrix::GetRotationMatrix ( ) const

Rotation part of the matrix.

The result is a 4x4 identity matrix with the upper left 3x3 copied from this matrix.

◆ GetScale()

decVector decMatrix::GetScale ( ) const

Scaling of the matrix.

This works only if the matrix is the product of translations, rotations and scaling. The returned scaling is always positive.

◆ Invert()

decMatrix decMatrix::Invert ( ) const

Inverse of this matrix if the inverse is possible.

◆ IsEqualTo()

bool decMatrix::IsEqualTo ( const decMatrix matrix,
float  threshold = 0.0001 
) const

Matrix is cell wise equal to anither one in respect to a threshold.

◆ Normalize()

void decMatrix::Normalize ( )

Normalize matrix.

Modifies matrix with scaling removed. Only normalized matrices are safe to be used with the GetEulerAngles() and ToQuaternion() calls since scaling interferes with the calculation.

This calls the same as this code

decVector GetPosition() const
Position of the matrix.
decVector TransformView() const
View vector of this matrix.
void SetWorld(const decVector &pos, const decVector &view, const decVector &up)
Set world space matrix.
decVector TransformUp() const
Up vector of this matrix.

but is safe against 0-scaling. In such a case a 0-rotation matrix is set.

◆ Normalized()

decMatrix decMatrix::Normalized ( ) const

Normalize matrix.

Returns matrix with scaling removed. Only normalized matrices are safe to be used with the GetEulerAngles() and ToQuaternion() calls since scaling interferes with the calculation.

This calls the same as this code

decMatrix::CreateWorld(m.GetPosition(), m.TransformView(), m.TransformUp())
static decMatrix CreateWorld(const decVector &pos, const decVector &view, const decVector &up)
Create new world space matrix.

but is safe against 0-scaling. In such a case a 0-rotation matrix is created.

◆ operator*() [1/4]

decMatrix decMatrix::operator* ( const decMatrix m) const

Retrieves a new matrix with this matrix multiplied with another one.

◆ operator*() [2/4]

decVector decMatrix::operator* ( const decVector v) const

Transforms vector by this matrix.

◆ operator*() [3/4]

decVector4 decMatrix::operator* ( const decVector4 v) const

Transforms 4 component vector by this matrix.

◆ operator*() [4/4]

decMatrix decMatrix::operator* ( float  k) const

Retrieves a new matrix with this matrix scaled by k.

◆ operator*=() [1/2]

decMatrix& decMatrix::operator*= ( const decMatrix m)

Multiplies this matrix with another one.

◆ operator*=() [2/2]

decMatrix& decMatrix::operator*= ( float  k)

Multiplies the cells of this matrix with a value k.

◆ operator+()

decMatrix decMatrix::operator+ ( const decMatrix m) const

Retrieves a new matrix with the sum of this matrix with another one.

◆ operator+=()

decMatrix& decMatrix::operator+= ( const decMatrix m)

Adds the cells of another matrix to this one.

◆ operator-()

decMatrix decMatrix::operator- ( const decMatrix m) const

Retrieves a new matrix with the difference of this matrix to another one.

◆ operator-=()

decMatrix& decMatrix::operator-= ( const decMatrix m)

Subtracts the cells of another matrix from this vector.

◆ operator/()

decMatrix decMatrix::operator/ ( float  k) const

Matrix with this matrix divided by k.

If k is 0 an exception is thrown.

◆ operator/=()

decMatrix& decMatrix::operator/= ( float  k)

Divide cells of this matrix by a value k.

If the value k is 0 an exception is thrown.

◆ operator=()

decMatrix& decMatrix::operator= ( const decMatrix m)

Set cells of this matrix to the values of another one.

◆ QuickAddTo()

decMatrix& decMatrix::QuickAddTo ( const decMatrix m)

Quick cell wise adds another matrix to this matrix.

◆ QuickDeterminant()

float decMatrix::QuickDeterminant ( ) const

Quick calculates the determinant of this matrix.

◆ QuickInvert()

decMatrix decMatrix::QuickInvert ( ) const

Quick calculates the inverse of this matrix.

◆ QuickMultiply() [1/2]

decMatrix decMatrix::QuickMultiply ( const decMatrix matrix) const

Quick multiplies this matrix with another one.

◆ QuickMultiply() [2/2]

decMatrix decMatrix::QuickMultiply ( float  k) const

Quick multiplies this matrix with a value k.

◆ QuickMultiplyRotation()

decMatrix decMatrix::QuickMultiplyRotation ( const decMatrix matrix) const

Quick multiplies this matrix rotation part with another one.

◆ SetBiasMatrix()

void decMatrix::SetBiasMatrix ( )

Set bias matrix which multiplies all coordinates by 0.5 and offsets them by 0.5.

◆ SetCamera()

void decMatrix::SetCamera ( const decVector pos,
const decVector view,
const decVector up 
)

Set camera space matrix.

A camera space matrix is different from a world space matrix in that it does transform positions from an world coordinate system into a coordinate system where the x axis points right, the y axis up and the z-axis straight into the screen. Best example to understand is a rotation. A world space matrix rotates a vector pointing straight down the z axis into the view vector used to create the matrix. A camera matrix though transforms a vector pointing into the view direction of the camera matrix into a vector pointing straight down the z axis. Hence the camera matrix is kinda the inverse of the world matrix what goes for the final transformation.

Parameters
posPosition of camera
viewView vector of camera not necessary normalized
upUp vector of camera not necessary normalized

◆ SetClipSpace()

void decMatrix::SetClipSpace ( )

Set matrix to transform a projection matrix into cliping space.

In cliping space the view frustum turns into a cube.

◆ SetFromQuaternion() [1/2]

void decMatrix::SetFromQuaternion ( const decQuaternion q)

Set rotation matrix from a quaternion.

Parameters
qRotation quaternion

◆ SetFromQuaternion() [2/2]

void decMatrix::SetFromQuaternion ( const decQuaternion q,
const decVector pivot 
)

Set rotation matrix from a quaternion.

◆ SetIdentity()

void decMatrix::SetIdentity ( )

Sets identity matrix.

◆ SetOrtho()

void decMatrix::SetOrtho ( int  left,
int  right,
int  top,
int  bottom,
int  znear,
int  zfar 
)

Set orthogonal projection matrix.

Parameters
leftLeft cliping plane position
rightRight cliping plane position
topTop cliping plane position
bottomBottom cliping plane position
znearDistance to near cliping plane
zfarDistance to far cliping plane

◆ SetProjection()

void decMatrix::SetProjection ( int  width,
int  height,
float  fov,
float  fovRatio,
float  znear,
float  zfar 
)

Set projection matrix based on a finite view frustum.

The width and height are used to derive the aspect ratio from.

Parameters
widthWidth of the viewport window
heightHeight of the viewport window
fovVertical field of view of the projection. Indicates the radian angle from the left side of the view frustum to the right side
fovRatioAspect ratio of the horizontal to the vertical field of view.
znearDistance to near cliping plane
zfarDistance to far cliping plane

◆ SetProjectionInfinite()

void decMatrix::SetProjectionInfinite ( int  width,
int  height,
float  fov,
float  fovRatio,
float  znear 
)

Set projection matrix based on a infinite view frustum.

The width and height are used to derive the aspect ratio from.

Parameters
widthWidth of the viewport window
heightHeight of the viewport window
fovVertical field of view of the projection. Indicates the radian angle from the left side of the view frustum to the right side
fovRatioAspect ratio of the horizontal to the vertical field of view.
znearDistance to near cliping plane

◆ SetRotation() [1/2]

void decMatrix::SetRotation ( const decVector r)

Set rotation around the all three axes matrix.

This matrix is the same as first applying a z axis roation, then an x axis rotation and then an y axis rotation.

◆ SetRotation() [2/2]

void decMatrix::SetRotation ( float  rx,
float  ry,
float  rz 
)

Set rotation around the all three axes matrix.

This matrix is the same as first applying a z axis roation, then an x axis rotation and then an y axis rotation.

◆ SetRotationAxis()

void decMatrix::SetRotationAxis ( const decVector axis,
float  angle 
)

Sets rotation around an arbitrary axis matrix.

◆ SetRotationX()

void decMatrix::SetRotationX ( float  arc)

Sets rotation around the x axis matrix.

◆ SetRotationY()

void decMatrix::SetRotationY ( float  arc)

Sets rotation around the y axis matrix.

◆ SetRotationZ()

void decMatrix::SetRotationZ ( float  arc)

Sets rotation around the z axis matrix.

◆ SetRT()

void decMatrix::SetRT ( const decVector rot,
const decVector pos 
)

Set rotation-translation matrix.

This is the same as first doing a 3-axis rotation and then a translation.

Parameters
rotRotation vector
posTranslation vector

◆ SetScale() [1/2]

void decMatrix::SetScale ( const decVector s)

Sets scaling matrix.

◆ SetScale() [2/2]

void decMatrix::SetScale ( float  sx,
float  sy,
float  sz 
)

Sets scaling matrix.

◆ SetSRT()

void decMatrix::SetSRT ( const decVector scale,
const decVector rot,
const decVector pos 
)

Set scale-rotation-translation matrix.

This is the same as first doing a scaling, then a 3-axis rotation and then a translation.

Parameters
scaleScaling vector
rotRotation vector
posTranslation vector

◆ SetSVUT()

void decMatrix::SetSVUT ( const decVector scale,
const decVector view,
const decVector up,
const decVector pos 
)

Set scale-view-up-translation matrix.

This is the same as first doing a scaling, then a world space matrix.

Parameters
scaleScaling vector
viewView vector
upUp vector
posTranslation vector

◆ SetTranslation() [1/2]

void decMatrix::SetTranslation ( const decVector t)

Sets translation matrix.

◆ SetTranslation() [2/2]

void decMatrix::SetTranslation ( float  x,
float  y,
float  z 
)

Sets translation matrix.

◆ SetVU()

void decMatrix::SetVU ( const decVector view,
const decVector up 
)

Set view-up matrix.

This is the same as doing a world space matrix but with the zero vector as position.

Parameters
viewView vector
upUp vector

◆ SetWorld() [1/3]

void decMatrix::SetWorld ( const decVector pos,
const decQuaternion orientation 
)

Set world space matrix.

A world matrix is used to transform coordinates from the coordinate system of one object to another one.

Parameters
posPosition of object
orientationOrientation

◆ SetWorld() [2/3]

void decMatrix::SetWorld ( const decVector pos,
const decQuaternion orientation,
const decVector scale 
)

Set world space matrix.

A world matrix is used to transform coordinates from the object local coordinate system to the world coordinate system.

◆ SetWorld() [3/3]

void decMatrix::SetWorld ( const decVector pos,
const decVector view,
const decVector up 
)

Set world space matrix.

A world matrix is used to transform coordinates from the coordinate system of one object to another one.

Parameters
posPosition of object
viewView vector of object not necessary normalized
upUp vector of object not necessary normalized

◆ ToQuaternion()

decQuaternion decMatrix::ToQuaternion ( ) const

Convert matrix into a rotation quaternion.

This conversion is well defined in contrast to the rotation vector function.

◆ Transform() [1/4]

void decMatrix::Transform ( decVector result,
float  x,
float  y,
float  z 
) const

Transforma vector.

◆ Transform() [2/4]

void decMatrix::Transform ( decVector4 result,
float  x,
float  y,
float  z,
float  w 
) const

Transforma vector.

◆ Transform() [3/4]

decVector decMatrix::Transform ( float  x,
float  y,
float  z 
) const

Transforma vector.

◆ Transform() [4/4]

decVector4 decMatrix::Transform ( float  x,
float  y,
float  z,
float  w 
) const

Transforma vector.

◆ TransformNormal()

decVector decMatrix::TransformNormal ( const decVector normal) const

Transforms a normal by this matrix.

This is the same as transforming the normal by only the rotation part of it.

◆ TransformRight()

decVector decMatrix::TransformRight ( ) const

Right vector of this matrix.

This is the same as transforing the vector (1,0,0) by this matrix but faster.

◆ TransformUp()

decVector decMatrix::TransformUp ( ) const

Up vector of this matrix.

This is the same as transforing the vector (0,1,0) by this matrix but faster.

◆ TransformView()

decVector decMatrix::TransformView ( ) const

View vector of this matrix.

This is the same as transforing the vector (0,0,1) by this matrix but faster.

Member Data Documentation

◆ a11

float decMatrix::a11

◆ a12

float decMatrix::a12

◆ a13

float decMatrix::a13

◆ a14

float decMatrix::a14

◆ a21

float decMatrix::a21

◆ a22

float decMatrix::a22

◆ a23

float decMatrix::a23

◆ a24

float decMatrix::a24

◆ a31

float decMatrix::a31

◆ a32

float decMatrix::a32

◆ a33

float decMatrix::a33

◆ a34

float decMatrix::a34

◆ a41

float decMatrix::a41

◆ a42

float decMatrix::a42

◆ a43

float decMatrix::a43

◆ a44

float decMatrix::a44

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