PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
Loading...
Searching...
No Matches
PureTransformMatrix Class Reference

PURE 3D-transformation matrix class. More...

Detailed Description

PURE 3D-transformation matrix class.

PURE uses the left-handed Cartesian coordinate system. This means the XZ plane is horizontal, the XY and and YZ planes are vertical, a positive X value means right, a positive Y value means up, and a positive Z value means forward.

Definition at line 23 of file PureTransformMatrix.h.

#include <PureTransformMatrix.h>

+ Inheritance diagram for PureTransformMatrix:

Public Member Functions

 PureTransformMatrix ()
 Creates an identity matrix.
 
 PureTransformMatrix (const PureTransformMatrix &cm)
 
 PureTransformMatrix (const TPURE_NOTABLE_MATRICES &nm)
 Creates the requested matrix.
 
virtual ~PureTransformMatrix ()
 
void SetRotationX (TPureFloat anglex)
 Sets the matrix to a rotation matrix around X-axis.
 
void SetRotationY (TPureFloat angley)
 Sets the matrix to a rotation matrix around Y-axis.
 
void SetRotationZ (TPureFloat anglez)
 Sets the matrix to a rotation matrix around Z-axis.
 
void SetTranslation (TPureFloat x, TPureFloat y, TPureFloat z)
 Sets the matrix to a translation matrix.
 
TPureFloat getScaleX () const
 Gets the scaling on the X-axis.
 
TPureFloat getScaleY () const
 Gets the scaling on the Y-axis.
 
TPureFloat getScaleZ () const
 Gets the scaling on the Z-axis.
 
void SetScale (TPureFloat x, TPureFloat y, TPureFloat z)
 Sets the scalings on the 3 axes.
 
void SetScaleX (TPureFloat x)
 Sets the matrix to a scaling matrix only on the X-axis.
 
void SetScaleY (TPureFloat y)
 Sets the matrix to a scaling matrix only on the Y-axis.
 
void SetScaleZ (TPureFloat z)
 Sets the matrix to a scaling matrix only on the Z-axis.
 
void SetMirrorXY ()
 Sets the matrix to a mirroring matrix on the XY planes.
 
void SetMirrorXZ ()
 Sets the matrix to a mirroring matrix on the XZ planes.
 
void SetMirrorYZ ()
 Sets the matrix to a mirroring matrix on the YZ planes.
 
void SetFrustum (float left, float right, float bottom, float top, float n, float f)
 Sets the matrix to represent a viewing frustum in world coordinate system.
 
void SetFrustumByFovX (float fovx, float aspect, float zNear, float zFar)
 Sets the matrix to represent a viewing frustum in world coordinate system.
 
void SetFrustumByFovY (float fovy, float aspect, float zNear, float zFar)
 Sets the matrix to represent a viewing frustum in world coordinate system.
 
void SetLookAt (const PureVector &pos, const PureVector &target, const PureVector &up)
 Sets the matrix to represent a view matrix in world coordinate system.
 
- Public Member Functions inherited from PureMatrix
 PureMatrix ()
 Creates an identity matrix.
 
 PureMatrix (const PureMatrix &cm)
 
 PureMatrix (const TPURE_NOTABLE_MATRICES &nm)
 Creates the requested matrix.
 
virtual ~PureMatrix ()
 
TPureFloat get (TPureByte row, TPureByte col) const
 Gets the element at the given row and column.
 
void Set (TPureByte row, TPureByte col, TPureFloat value)
 Sets the element at the given row and column.
 
const TPureFloatget () const
 Returns the matrix array as is.
 
TPureBool isZero () const
 Is it a zero matrix?
 
void SetZero ()
 Sets the matrix to zero matrix.
 
TPureBool isIdentity () const
 Is it an identity matrix?
 
void SetIdentity ()
 Sets the matrix to identity matrix.
 
void Transpose ()
 Transposes the matrix.
 
const TPureFloatgetTransposed ()
 Returns the matrix array in its transposed form without actually modifying the matrix.
 
TPureFloat getDeterminant () const
 Returns the determinant of the matrix.
 
TPureBool isInvertible () const
 Returns if the matrix is invertible.
 
TPureBool invert ()
 Inverts the matrix.
 
const TPureFloatgetInverse ()
 Returns the matrix array in its inverted form without actually modifying the matrix.
 
TPureBool operator== (const PureMatrix &cm) const
 Equals to operator.
 
TPureBool operator!= (const PureMatrix &cm) const
 Not equals to operator.
 
PureMatrixoperator= (const PureMatrix &cm)
 Assignment operator.
 
PureMatrix operator+ (const PureMatrix &cm) const
 Addition operator.
 
PureMatrixoperator+= (const PureMatrix &cm)
 Addition assignment operator.
 
PureMatrix operator- (const PureMatrix &cm) const
 Subtraction operator.
 
PureMatrixoperator-= (const PureMatrix &cm)
 Subtraction assignment operator.
 
PureMatrix operator* (const PureMatrix &cm) const
 Multiplication by matrix operator.
 
PureMatrixoperator*= (const PureMatrix &cm)
 Multiplication assignment operator.
 
PureMatrix operator* (const TPureFloat &scalar) const
 Multiplication by scalar operator.
 
PureMatrixoperator*= (const TPureFloat &scalar)
 Multiplication assignment operator.
 
PureVector operator* (const PureVector &vec) const
 Multiplication by vector operator.
 
TPureFloatoperator() (const TPureByte &row, const TPureByte &col)
 Access element operator operator.
 
const TPureFloatoperator() (const TPureByte &row, const TPureByte &col) const
 Access element operator operator.
 

Static Public Member Functions

static const PureTransformMatrixgetZero ()
 Gets a constant zero matrix.
 
static const PureTransformMatrixgetIdentity ()
 Gets a constant identity matrix.
 
- Static Public Member Functions inherited from PureMatrix
static const PureMatrixgetZero ()
 Gets a constant zero matrix.
 
static const PureMatrixgetIdentity ()
 Gets a constant identity matrix.
 

Static Private Attributes

static PureTransformMatrix matIdentity
 Static zero matrix.
 
static PureTransformMatrix matZero
 Static identity matrix.
 

Additional Inherited Members

- Protected Attributes inherited from PureMatrix
TPureFloat mat [4][4]
 Values.
 

Constructor & Destructor Documentation

◆ PureTransformMatrix() [1/3]

PureTransformMatrix::PureTransformMatrix ( )

Creates an identity matrix.

Definition at line 39 of file PureTransformMatrix.cpp.

◆ PureTransformMatrix() [2/3]

PureTransformMatrix::PureTransformMatrix ( const PureTransformMatrix & cm)

Definition at line 44 of file PureTransformMatrix.cpp.

◆ PureTransformMatrix() [3/3]

PureTransformMatrix::PureTransformMatrix ( const TPURE_NOTABLE_MATRICES & nm)
explicit

Creates the requested matrix.

Definition at line 53 of file PureTransformMatrix.cpp.

◆ ~PureTransformMatrix()

PureTransformMatrix::~PureTransformMatrix ( )
virtual

Definition at line 59 of file PureTransformMatrix.cpp.

Member Function Documentation

◆ getIdentity()

const PureTransformMatrix & PureTransformMatrix::getIdentity ( )
static

Gets a constant identity matrix.

Definition at line 30 of file PureTransformMatrix.cpp.

◆ getScaleX()

TPureFloat PureTransformMatrix::getScaleX ( ) const

Gets the scaling on the X-axis.

Definition at line 125 of file PureTransformMatrix.cpp.

◆ getScaleY()

TPureFloat PureTransformMatrix::getScaleY ( ) const

Gets the scaling on the Y-axis.

Definition at line 134 of file PureTransformMatrix.cpp.

◆ getScaleZ()

TPureFloat PureTransformMatrix::getScaleZ ( ) const

Gets the scaling on the Z-axis.

Definition at line 143 of file PureTransformMatrix.cpp.

◆ getZero()

const PureTransformMatrix & PureTransformMatrix::getZero ( )
static

Gets a constant zero matrix.

Definition at line 21 of file PureTransformMatrix.cpp.

◆ SetFrustum()

void PureTransformMatrix::SetFrustum ( float left,
float right,
float bottom,
float top,
float n,
float f )

Sets the matrix to represent a viewing frustum in world coordinate system.

It can be used to produce perspective projection, typically from eye space to clip space. Assuming that the eye is located at (0, 0, 0), following statements we can make:

  • point specified by (left, bottom, n) on the near clipping plane is mapped to the lower left corner of the window;
  • point specified by (right, top, n) on the near clipping plane is mapped to the upper right corner of the window.

Depth buffer precision is affected by the values specified for n and f. The greater the ratio of f to n is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other.

Parameters
leftLeft clipping plane distance to the viewer in eye space on X direction.
rightRight clipping plane distance to the viewer in eye space on X direction. Must be greater than left.
bottomBottom clipping plane distance to the viewer in eye space on Y direction.
topTop clipping plane distance to the viewer in eye space on Y direction. Must be greater than bottom.
nNear clipping plane distance to the viewer in eye space on Z direction. Must be greater than 0.
fFar clipping plane distance to the viewer in eye space on Z direction. Must be greater than n.

Definition at line 235 of file PureTransformMatrix.cpp.

◆ SetFrustumByFovX()

void PureTransformMatrix::SetFrustumByFovX ( float fovx,
float aspect,
float zNear,
float zFar )

Sets the matrix to represent a viewing frustum in world coordinate system.

It can be used to produce perspective projection, typically from eye space to clip space.

Depth buffer precision is affected by the values specified for zNear and zFar. The greater the ratio of zFar to zNear is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other.

Parameters
fovxThe field of vew angle in X direction. Must be greater than 0.
aspectSpecifies the aspect ratio that determines the field of view in the X direction. Typically the aspect ratio is the ratio of viewport width to viewport height. Must be greater than 0.
zNearNear clipping plane distance to the viewer in eye space on Z direction. Must be greater than 0.
zFarFar clipping plane distance to the viewer in eye space on Z direction. Must be greater than zNear.

Definition at line 278 of file PureTransformMatrix.cpp.

◆ SetFrustumByFovY()

void PureTransformMatrix::SetFrustumByFovY ( float fovy,
float aspect,
float zNear,
float zFar )

Sets the matrix to represent a viewing frustum in world coordinate system.

It can be used to produce perspective projection, typically from eye space to clip space.

Depth buffer precision is affected by the values specified for zNear and zFar. The greater the ratio of zFar to zNear is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other.

Parameters
fovyThe field of vew angle in Y direction. Must be greater than 0.
aspectSpecifies the aspect ratio that determines the field of view in the X direction. Typically the aspect ratio is the ratio of viewport width to viewport height. Must be greater than 0.
zNearNear clipping plane distance to the viewer in eye space on Z direction. Must be greater than 0.
zFarFar clipping plane distance to the viewer in eye space on Z direction. Must be greater than zNear.

Definition at line 309 of file PureTransformMatrix.cpp.

◆ SetLookAt()

void PureTransformMatrix::SetLookAt ( const PureVector & vPos,
const PureVector & vTarget,
const PureVector & vUp )

Sets the matrix to represent a view matrix in world coordinate system.

Transforms everything based on camera position and direction.

Parameters
vPosEye position.
vTargetWhere we are looking at.
vUpAn Up vector representing positive direction on Y-angle, usually the camera's Up vector.

Definition at line 337 of file PureTransformMatrix.cpp.

◆ SetMirrorXY()

void PureTransformMatrix::SetMirrorXY ( )

Sets the matrix to a mirroring matrix on the XY planes.

Definition at line 192 of file PureTransformMatrix.cpp.

◆ SetMirrorXZ()

void PureTransformMatrix::SetMirrorXZ ( )

Sets the matrix to a mirroring matrix on the XZ planes.

Definition at line 202 of file PureTransformMatrix.cpp.

◆ SetMirrorYZ()

void PureTransformMatrix::SetMirrorYZ ( )

Sets the matrix to a mirroring matrix on the YZ planes.

Definition at line 212 of file PureTransformMatrix.cpp.

◆ SetRotationX()

void PureTransformMatrix::SetRotationX ( TPureFloat anglex)

Sets the matrix to a rotation matrix around X-axis.

Definition at line 68 of file PureTransformMatrix.cpp.

◆ SetRotationY()

void PureTransformMatrix::SetRotationY ( TPureFloat angley)

Sets the matrix to a rotation matrix around Y-axis.

Definition at line 83 of file PureTransformMatrix.cpp.

◆ SetRotationZ()

void PureTransformMatrix::SetRotationZ ( TPureFloat anglez)

Sets the matrix to a rotation matrix around Z-axis.

Definition at line 98 of file PureTransformMatrix.cpp.

◆ SetScale()

void PureTransformMatrix::SetScale ( TPureFloat x,
TPureFloat y,
TPureFloat z )

Sets the scalings on the 3 axes.

Definition at line 152 of file PureTransformMatrix.cpp.

◆ SetScaleX()

void PureTransformMatrix::SetScaleX ( TPureFloat x)

Sets the matrix to a scaling matrix only on the X-axis.

Definition at line 165 of file PureTransformMatrix.cpp.

◆ SetScaleY()

void PureTransformMatrix::SetScaleY ( TPureFloat y)

Sets the matrix to a scaling matrix only on the Y-axis.

Definition at line 174 of file PureTransformMatrix.cpp.

◆ SetScaleZ()

void PureTransformMatrix::SetScaleZ ( TPureFloat z)

Sets the matrix to a scaling matrix only on the Z-axis.

Definition at line 183 of file PureTransformMatrix.cpp.

◆ SetTranslation()

void PureTransformMatrix::SetTranslation ( TPureFloat x,
TPureFloat y,
TPureFloat z )

Sets the matrix to a translation matrix.

Definition at line 113 of file PureTransformMatrix.cpp.

Member Data Documentation

◆ matIdentity

PureTransformMatrix PureTransformMatrix::matIdentity
staticprivate

Static zero matrix.

Definition at line 74 of file PureTransformMatrix.h.

◆ matZero

PureTransformMatrix PureTransformMatrix::matZero
staticprivate

Static identity matrix.

Definition at line 75 of file PureTransformMatrix.h.


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