Drag[en]gine Game Engine  1.21
decDMatrix Class Reference

4x4 Component Matrix double precision. Same as the decDMatrix class but with double precision. More...

#include <decDMatrix.h>

Public Member Functions

Constructors and Destructors
 decDMatrix ()
 Create new matrix initialized to identity. More...
 
 decDMatrix (const decDMatrix &m)
 Create copy of a matrix. More...
 
 decDMatrix (const decMatrix &m)
 Create copy of a float matrix. More...
 
Management
void SetIdentity ()
 Sets identity matrix. More...
 
void SetTranslation (double x, double y, double z)
 Sets translation matrix. More...
 
void SetTranslation (const decDVector &t)
 Sets translation matrix. More...
 
void SetScale (double sx, double sy, double sz)
 Sets scaling matrix. More...
 
void SetScale (const decDVector &s)
 Sets scaling matrix. More...
 
void SetRotationX (double arc)
 Sets rotation around the x axis matrix. More...
 
void SetRotationY (double arc)
 Sets rotation around the y axis matrix. More...
 
void SetRotationZ (double arc)
 Sets rotation around the z axis matrix. More...
 
void SetRotation (double rx, double ry, double rz)
 Set rotation around the all three axes matrix. More...
 
void SetRotation (const decDVector &r)
 Set rotation around the all three axes matrix. More...
 
void SetRotationAxis (const decDVector &axis, double angle)
 Sets rotation around an arbitrary axis matrix. More...
 
void SetWorld (const decDVector &pos, const decDVector &view, const decDVector &up)
 Set world space matrix. More...
 
void SetWorld (const decDVector &pos, const decQuaternion &orientation)
 Set world space matrix. More...
 
void SetWorld (const decDVector &pos, const decQuaternion &orientation, const decDVector &scale)
 Set world space matrix. More...
 
void SetCamera (const decDVector &pos, const decDVector &view, const decDVector &up)
 Set camera space matrix. More...
 
void SetProjection (int width, int height, double fov, double fovRatio, double znear, double zfar)
 Set projection matrix based on a finite view frustum. More...
 
void SetProjectionInfinite (int width, int height, double fov, double fovRatio, double 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 decDVector &rot, const decDVector &pos)
 Set rotation-translation matrix. More...
 
void SetST (const decDVector &scale, const decDVector &translate)
 Set scale-translation matrix. More...
 
void SetSRT (const decDVector &scale, const decDVector &rot, const decDVector &pos)
 Set scale-rotation-translation matrix. More...
 
void SetSVUT (const decDVector &scale, const decDVector &view, const decDVector &up, const decDVector &pos)
 Set scale-view-up-translation matrix. More...
 
void SetVU (const decDVector &view, const decDVector &up)
 Set view-up matrix. More...
 
void SetFromQuaternion (const decQuaternion &q)
 Set rotation matrix from a quaternion. More...
 
void SetFromQuaternion (const decQuaternion &q, const decDVector &pivot)
 Set rotation matrix from a quaternion. More...
 
void Set (const decMatrix &matrix)
 Set matrix from a single precision matrix. More...
 
double Determinant () const
 Calculates the determinant of the matrix. More...
 
decDMatrix Invert () const
 Inverse of this matrix if the inverse is possible. More...
 
decDMatrix Transpose () const
 Transpose of this matrix. More...
 
decDVector 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...
 
decDVector GetScale () const
 Scaling of the matrix. More...
 
decDVector GetPosition () const
 Position of the matrix. More...
 
decDVector TransformView () const
 View vector of this matrix. More...
 
decDVector TransformRight () const
 Right vector of this matrix. More...
 
decDVector TransformUp () const
 Up vector of this matrix. More...
 
decDVector TransformNormal (const decDVector &normal) const
 Transform normal by this matrix. More...
 
decDVector Transform (double x, double y, double z) const
 Transforms a vector. More...
 
decDVector4 Transform (double x, double y, double z, double w) const
 Transforms a vector. More...
 
void Transform (decDVector &result, double x, double y, double z) const
 Transforms a vector. More...
 
void Transform (decDVector4 &result, double x, double y, double z, double w) const
 Transforms a vector. More...
 
decDMatrix GetRotationMatrix () const
 Rotation part of the matrix. More...
 
void Normalize ()
 Normalize matrix. More...
 
decDMatrix Normalized () const
 Normalize matrix. More...
 
bool IsEqualTo (const decDMatrix &matrix, double threshold=DVECTOR_THRESHOLD) 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.

decDMatrix QuickMultiply (const decDMatrix &matrix) const
 Quick multiplies this matrix with another one. More...
 
decDMatrix QuickMultiplyRotation (const decDMatrix &matrix) const
 Quick multiplies this matrix rotation part with another one. More...
 
decDMatrix QuickMultiply (double k) const
 Quick multiplies this matrix with a value k. More...
 
double QuickDeterminant () const
 Quick calculates the determinant of this matrix. More...
 
decDMatrix QuickInvert () const
 Quick calculates the inverse of this matrix. More...
 
decDMatrixQuickAddTo (const decDMatrix &m)
 Quick cell wise adds another matrix to this matrix. More...
 
decMatrix ToMatrix () const
 Converts to a single precision matrix with possible loss of precision. More...
 
Operators
decDMatrixoperator= (const decDMatrix &m)
 Set cells of this matrix to the values of another one. More...
 
decDMatrixoperator+= (const decDMatrix &m)
 Adds the cells of another matrix to this one. More...
 
decDMatrixoperator-= (const decDMatrix &m)
 Subtracts the cells of another matrix from this vector. More...
 
decDMatrixoperator*= (double k)
 Multiplies the cells of this matrix with a value k. More...
 
decDMatrixoperator/= (double k)
 Divide cells of this matrix by a value k. More...
 
decDMatrixoperator*= (const decDMatrix &m)
 Multiplies this matrix with another one. More...
 
decDMatrix operator+ (const decDMatrix &m) const
 Retrieves a new matrix with the sum of this matrix with another one. More...
 
decDMatrix operator- (const decDMatrix &m) const
 Retrieves a new matrix with the difference of this matrix to another one. More...
 
decDMatrix operator* (double k) const
 Retrieves a new matrix with this matrix scaled by k. More...
 
decDMatrix operator/ (double k) const
 Retrieves a new matrix with this matrix divided by k. If k is 0 an exception is thrown. More...
 
decDMatrix operator* (const decDMatrix &m) const
 Retrieves a new matrix with this matrix multiplied with another one. More...
 
decDVector operator* (const decDVector &v) const
 Transforms vector by this matrix. More...
 
decDVector4 operator* (const decDVector4 &v) const
 Transforms 4 component vector by this matrix. More...
 

Static Public Member Functions

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

Public Attributes

Cells

The first number indicates the row the second the column.

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

Detailed Description

4x4 Component Matrix double precision. Same as the decDMatrix class but with double precision.

Constructor & Destructor Documentation

◆ decDMatrix() [1/3]

decDMatrix::decDMatrix ( )

Create new matrix initialized to identity.

◆ decDMatrix() [2/3]

decDMatrix::decDMatrix ( const decDMatrix m)

Create copy of a matrix.

◆ decDMatrix() [3/3]

decDMatrix::decDMatrix ( const decMatrix m)

Create copy of a float matrix.

Member Function Documentation

◆ CreateBiasMatrix()

static decDMatrix decDMatrix::CreateBiasMatrix ( )
static

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

◆ CreateCamera()

static decDMatrix decDMatrix::CreateCamera ( const decDVector pos,
const decDVector view,
const decDVector 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 decDMatrix decDMatrix::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 decDMatrix decDMatrix::CreateFromQuaternion ( const decQuaternion q)
static

Create rotation matrix from a quaternion.

Parameters
qRotation quaternion

◆ CreateFromQuaternion() [2/2]

static decDMatrix decDMatrix::CreateFromQuaternion ( const decQuaternion q,
const decDVector pivot 
)
static

Create rotation matrix from a quaternion.

◆ CreateIdentity()

static decDMatrix decDMatrix::CreateIdentity ( )
static

Create new identity matrix.

◆ CreateOrtho()

static decDMatrix decDMatrix::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 decDMatrix decDMatrix::CreateProjection ( int  width,
int  height,
double  fov,
double  fovRatio,
double  znear,
double  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 decDMatrix decDMatrix::CreateProjectionInfinite ( int  width,
int  height,
double  fov,
double  fovRatio,
double  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 decDMatrix decDMatrix::CreateRotation ( const decDVector 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 decDMatrix decDMatrix::CreateRotation ( double  rx,
double  ry,
double  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 decDMatrix decDMatrix::CreateRotationAxis ( const decDVector axis,
double  angle 
)
static

Create new rotation around an arbitrary axis matrix.

◆ CreateRotationX()

static decDMatrix decDMatrix::CreateRotationX ( double  arc)
static

Create new rotation around the x axis matrix.

◆ CreateRotationY()

static decDMatrix decDMatrix::CreateRotationY ( double  arc)
static

Create new rotation around the y axis matrix.

◆ CreateRotationZ()

static decDMatrix decDMatrix::CreateRotationZ ( double  arc)
static

Create new rotation around the z axis matrix.

◆ CreateRT()

static decDMatrix decDMatrix::CreateRT ( const decDVector rot,
const decDVector 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 decDMatrix decDMatrix::CreateScale ( const decDVector s)
static

Create new scaling matrix.

◆ CreateScale() [2/2]

static decDMatrix decDMatrix::CreateScale ( double  sx,
double  sy,
double  sz 
)
static

Create new scaling matrix.

◆ CreateSRT()

static decDMatrix decDMatrix::CreateSRT ( const decDVector scale,
const decDVector rot,
const decDVector 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

◆ CreateST()

static decDMatrix decDMatrix::CreateST ( const decDVector scale,
const decDVector translate 
)
static

Create scale-translation matrix.

This is the same as first doing a scaling and then a translation.

◆ CreateSVUT()

static decDMatrix decDMatrix::CreateSVUT ( const decDVector scale,
const decDVector view,
const decDVector up,
const decDVector 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 decDMatrix decDMatrix::CreateTranslation ( const decDVector t)
static

Create new translation matrix.

◆ CreateTranslation() [2/2]

static decDMatrix decDMatrix::CreateTranslation ( double  x,
double  y,
double  z 
)
static

Create new translation matrix.

◆ CreateVU()

static decDMatrix decDMatrix::CreateVU ( const decDVector view,
const decDVector 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 decDMatrix decDMatrix::CreateWorld ( const decDVector pos,
const decDVector view,
const decDVector 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

◆ CreateWorld() [2/3]

static decDMatrix decDMatrix::CreateWorld ( const decDVector 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() [3/3]

static decDMatrix decDMatrix::CreateWorld ( const decDVector pos,
const decQuaternion orientation,
const decDVector 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.

◆ Determinant()

double decDMatrix::Determinant ( ) const

Calculates the determinant of the matrix.

◆ GetEulerAngles()

decDVector decDMatrix::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()

decDVector decDMatrix::GetPosition ( ) const

Position of the matrix.

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

◆ GetRotationMatrix()

decDMatrix decDMatrix::GetRotationMatrix ( ) const

Rotation part of the matrix.

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

◆ GetScale()

decDVector decDMatrix::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()

decDMatrix decDMatrix::Invert ( ) const

Inverse of this matrix if the inverse is possible.

◆ IsEqualTo()

bool decDMatrix::IsEqualTo ( const decDMatrix matrix,
double  threshold = DVECTOR_THRESHOLD 
) const

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

◆ Normalize()

void decDMatrix::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

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

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

◆ Normalized()

decDMatrix decDMatrix::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

decDMatrix::CreateWorld(m.GetPosition(), m.TransformView(), m.TransformUp())
static decDMatrix CreateWorld(const decDVector &pos, const decDVector &view, const decDVector &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]

decDMatrix decDMatrix::operator* ( const decDMatrix m) const

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

◆ operator*() [2/4]

decDVector decDMatrix::operator* ( const decDVector v) const

Transforms vector by this matrix.

◆ operator*() [3/4]

decDVector4 decDMatrix::operator* ( const decDVector4 v) const

Transforms 4 component vector by this matrix.

◆ operator*() [4/4]

decDMatrix decDMatrix::operator* ( double  k) const

Retrieves a new matrix with this matrix scaled by k.

◆ operator*=() [1/2]

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

Multiplies this matrix with another one.

◆ operator*=() [2/2]

decDMatrix& decDMatrix::operator*= ( double  k)

Multiplies the cells of this matrix with a value k.

◆ operator+()

decDMatrix decDMatrix::operator+ ( const decDMatrix m) const

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

◆ operator+=()

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

Adds the cells of another matrix to this one.

◆ operator-()

decDMatrix decDMatrix::operator- ( const decDMatrix m) const

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

◆ operator-=()

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

Subtracts the cells of another matrix from this vector.

◆ operator/()

decDMatrix decDMatrix::operator/ ( double  k) const

Retrieves a new matrix with this matrix divided by k. If k is 0 an exception is thrown.

◆ operator/=()

decDMatrix& decDMatrix::operator/= ( double  k)

Divide cells of this matrix by a value k.

If the value k is 0 an exception is thrown.

◆ operator=()

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

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

◆ QuickAddTo()

decDMatrix& decDMatrix::QuickAddTo ( const decDMatrix m)

Quick cell wise adds another matrix to this matrix.

◆ QuickDeterminant()

double decDMatrix::QuickDeterminant ( ) const

Quick calculates the determinant of this matrix.

◆ QuickInvert()

decDMatrix decDMatrix::QuickInvert ( ) const

Quick calculates the inverse of this matrix.

◆ QuickMultiply() [1/2]

decDMatrix decDMatrix::QuickMultiply ( const decDMatrix matrix) const

Quick multiplies this matrix with another one.

◆ QuickMultiply() [2/2]

decDMatrix decDMatrix::QuickMultiply ( double  k) const

Quick multiplies this matrix with a value k.

◆ QuickMultiplyRotation()

decDMatrix decDMatrix::QuickMultiplyRotation ( const decDMatrix matrix) const

Quick multiplies this matrix rotation part with another one.

◆ Set()

void decDMatrix::Set ( const decMatrix matrix)

Set matrix from a single precision matrix.

◆ SetBiasMatrix()

void decDMatrix::SetBiasMatrix ( )

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

◆ SetCamera()

void decDMatrix::SetCamera ( const decDVector pos,
const decDVector view,
const decDVector 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 decDMatrix::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 decDMatrix::SetFromQuaternion ( const decQuaternion q)

Set rotation matrix from a quaternion.

Parameters
qRotation quaternion

◆ SetFromQuaternion() [2/2]

void decDMatrix::SetFromQuaternion ( const decQuaternion q,
const decDVector pivot 
)

Set rotation matrix from a quaternion.

◆ SetIdentity()

void decDMatrix::SetIdentity ( )

Sets identity matrix.

◆ SetOrtho()

void decDMatrix::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 decDMatrix::SetProjection ( int  width,
int  height,
double  fov,
double  fovRatio,
double  znear,
double  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 decDMatrix::SetProjectionInfinite ( int  width,
int  height,
double  fov,
double  fovRatio,
double  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 decDMatrix::SetRotation ( const decDVector 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 decDMatrix::SetRotation ( double  rx,
double  ry,
double  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 decDMatrix::SetRotationAxis ( const decDVector axis,
double  angle 
)

Sets rotation around an arbitrary axis matrix.

◆ SetRotationX()

void decDMatrix::SetRotationX ( double  arc)

Sets rotation around the x axis matrix.

◆ SetRotationY()

void decDMatrix::SetRotationY ( double  arc)

Sets rotation around the y axis matrix.

◆ SetRotationZ()

void decDMatrix::SetRotationZ ( double  arc)

Sets rotation around the z axis matrix.

◆ SetRT()

void decDMatrix::SetRT ( const decDVector rot,
const decDVector 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 decDMatrix::SetScale ( const decDVector s)

Sets scaling matrix.

◆ SetScale() [2/2]

void decDMatrix::SetScale ( double  sx,
double  sy,
double  sz 
)

Sets scaling matrix.

◆ SetSRT()

void decDMatrix::SetSRT ( const decDVector scale,
const decDVector rot,
const decDVector 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

◆ SetST()

void decDMatrix::SetST ( const decDVector scale,
const decDVector translate 
)

Set scale-translation matrix.

This is the same as first doing a scaling and then a translation.

◆ SetSVUT()

void decDMatrix::SetSVUT ( const decDVector scale,
const decDVector view,
const decDVector up,
const decDVector 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 decDMatrix::SetTranslation ( const decDVector t)

Sets translation matrix.

◆ SetTranslation() [2/2]

void decDMatrix::SetTranslation ( double  x,
double  y,
double  z 
)

Sets translation matrix.

◆ SetVU()

void decDMatrix::SetVU ( const decDVector view,
const decDVector 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 decDMatrix::SetWorld ( const decDVector pos,
const decDVector view,
const decDVector 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

◆ SetWorld() [2/3]

void decDMatrix::SetWorld ( const decDVector 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() [3/3]

void decDMatrix::SetWorld ( const decDVector pos,
const decQuaternion orientation,
const decDVector scale 
)

Set world space matrix.

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

◆ ToMatrix()

decMatrix decDMatrix::ToMatrix ( ) const

Converts to a single precision matrix with possible loss of precision.

◆ ToQuaternion()

decQuaternion decDMatrix::ToQuaternion ( ) const

Convert matrix into a rotation quaternion.

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

◆ Transform() [1/4]

void decDMatrix::Transform ( decDVector result,
double  x,
double  y,
double  z 
) const

Transforms a vector.

◆ Transform() [2/4]

void decDMatrix::Transform ( decDVector4 result,
double  x,
double  y,
double  z,
double  w 
) const

Transforms a vector.

◆ Transform() [3/4]

decDVector decDMatrix::Transform ( double  x,
double  y,
double  z 
) const

Transforms a vector.

◆ Transform() [4/4]

decDVector4 decDMatrix::Transform ( double  x,
double  y,
double  z,
double  w 
) const

Transforms a vector.

◆ TransformNormal()

decDVector decDMatrix::TransformNormal ( const decDVector normal) const

Transform normal by this matrix.

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

◆ TransformRight()

decDVector decDMatrix::TransformRight ( ) const

Right vector of this matrix.

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

◆ TransformUp()

decDVector decDMatrix::TransformUp ( ) const

Up vector of this matrix.

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

◆ TransformView()

decDVector decDMatrix::TransformView ( ) const

View vector of this matrix.

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

◆ Transpose()

decDMatrix decDMatrix::Transpose ( ) const

Transpose of this matrix.

Member Data Documentation

◆ a11

double decDMatrix::a11

◆ a12

double decDMatrix::a12

◆ a13

double decDMatrix::a13

◆ a14

double decDMatrix::a14

◆ a21

double decDMatrix::a21

◆ a22

double decDMatrix::a22

◆ a23

double decDMatrix::a23

◆ a24

double decDMatrix::a24

◆ a31

double decDMatrix::a31

◆ a32

double decDMatrix::a32

◆ a33

double decDMatrix::a33

◆ a34

double decDMatrix::a34

◆ a41

double decDMatrix::a41

◆ a42

double decDMatrix::a42

◆ a43

double decDMatrix::a43

◆ a44

double decDMatrix::a44

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