Skip to content

class Mat4 (shared-side)

Available since version: 0.2

This class represents 4x4 matrix.

Constructor


Parameters:

Constructor

float value

Parameters:

  • float value: the initial value for each matrix cell.

Constructor

Vec4 v0, Vec4 v1, Vec4 v2, Vec4 v3

Parameters:

  • Vec4 v0: the initial value for 1st row of the matrix.
  • Vec4 v1: the initial value for 2nd row of the matrix.
  • Vec4 v2: the initial value for 3rd row of the matrix.
  • Vec4 v3: the initial value for 4th row of the matrix.

Properties

No properties.


Methods

makeIdentity

Available since version: 0.2

This method will set all cells to the identity matrix.

void makeIdentity()

makeZero

Available since version: 0.2

This method will set all cells to zero.

void makeZero()

makeOrthonormal

Available since version: 0.2

This method will make the matric orthonormal.

void makeOrthonormal()

isUpper3x3Orthonormal

Available since version: 0.2

This method will is used check whether upper 3x3 matrix components are orthonormal.

bool isUpper3x3Orthonormal()

Returns bool:

true if upper 3x3 components are orthonormal, otherwise false.


transpose

Available since version: 0.2

This method will return the transpose of the matrix. The transposed matrix is the one that has the Matrix4x4's columns exchanged with its rows.

Mat4 transpose()

Returns Mat4:

the transposed matrix.


inverse

Available since version: 0.2

This method will return the inverse of the matrix. Inverted matrix is such that if multiplied by the original would result in identity matrix.

Mat4 inverse()

Returns Mat4:

the inverted matrix.


inverseLinTrafo

Available since version: 0.2

This method will return the inverse linear transformation of the matrix. It works almost exactly the same as inverse
with the difference that translation is applied.

Mat4 inverseLinTrafo()

Returns Mat4:

the inverted matrix.


rotate

Available since version: 0.2

This method will apply the matrix rotation to given vector and return a new one.

Vec3 rotate(Vec3 vec)

Parameters:

  • Vec3 vec: the vector that will be used to produce the rotated one.

Returns Vec3:

the rotated vector.


getRightVector

Available since version: 0.2

This method will get the right vector from the matrix.

Vec3 getRightVector()

Returns Vec3:

the right vector.


setRightVector

Available since version: 0.2

This method will set the right vector for the matrix.

void setRightVector(Vec3 vec)

Parameters:

  • Vec3 vec: the new right vector for the matrix.

getAtVector

Available since version: 0.2

This method will get the at vector from the matrix.

Vec3 getAtVector()

Returns Vec3:

the at vector.


setAtVector

Available since version: 0.2

This method will set the at vector for the matrix.

void setAtVector(Vec3 vec)

Parameters:

  • Vec3 vec: the new at vector for the matrix.

getUpVector

Available since version: 0.2

This method will get the up vector from the matrix.

Vec3 getUpVector()

Returns Vec3:

the up vector.


setUpVector

Available since version: 0.2

This method will set the up vector for the matrix.

void setUpVector(Vec3 vec)

Parameters:

  • Vec3 vec: the new up vector for the matrix.

resetRotation

Available since version: 0.2

This method will reset the rotation of the matrix.

void resetRotation()

extractRotation

Available since version: 0.2

This method will extract the rotation matrix from the TRS matrix.

Mat3 extractRotation()

Returns Mat3:

the extracted rotation matrix.


extractScaling

Available since version: 0.2

This method will extract the scaling vector from the TRS matrix.

Vec3 extractScaling()

Returns Vec3:

the extracted scaling vector.


postRotateX

Available since version: 0.2

This method will perform the matrix post rotation operation on X axis.

void postRotateX(float angle)

Parameters:

  • float angle: the angle in degrees.

postRotateY

Available since version: 0.2

This method will perform the matrix post rotation operation on Y axis.

void postRotateY(float angle)

Parameters:

  • float angle: the angle in degrees.

postRotateZ

Available since version: 0.2

This method will perform the matrix post rotation operation on Z axis.

void postRotateZ(float angle)

Parameters:

  • float angle: the angle in degrees.

preScale

Available since version: 0.2

This method will perform the matrix pre scale operation.

void preScale(Vec3 scale)

Parameters:

  • Vec3 scale: the scale vector.

postScale

Available since version: 0.2

This method will perform the matrix post scale operation.

void postScale(Vec3 scale)

Parameters:

  • Vec3 scale: the scale vector.

static swap

Available since version: 0.2

This method will swap all cells between two matricies.

void swap(Mat4 mat1, Mat4 mat2)

Parameters:

  • Mat4 mat1: the matrix that will be used in swap operation.
  • Mat4 mat2: the matrix that will be used in swap operation.