Skip to content

class Mat3 (shared-side)

Available since version: 0.3.0

This class represents a 3x3 matrix.

Constructor

Mat3.new()

Parameters:

No parameters.

Constructor

Mat3.new(number value)

Parameters:

  • number value: Scalar initialization value.

Constructor

Mat3.new(Vec3 v0, Vec3 v1, Vec3 v2)

Parameters:

  • Vec3 v0: First row vector.
  • Vec3 v1: Second row vector.
  • Vec3 v2: Third row vector.

Properties

No properties.


Methods

makeIdentity

This method resets the matrix to identity.

void makeIdentity()

makeZero

This method sets all matrix elements to zero.

void makeZero()

makeOrthonormal

This method orthonormalizes the matrix basis vectors. This makes the basis vectors unit-length and mutually orthogonal.

void makeOrthonormal()

isUpper3x3Orthonormal

This method returns true if the matrix basis vectors are orthonormal.

boolean isUpper3x3Orthonormal()

Returns boolean:

True if orthonormal within epsilon tolerance.


transpose

This method returns the transposed matrix.

Mat3 transpose()

Returns Mat3:

Transposed matrix.


inverse

This method returns the inverse matrix.

Mat3 inverse()

Returns Mat3:

Inverse matrix.


rotate

This method rotates a vector by this matrix.

Vec3 rotate(Vec3 vec)

Parameters:

  • Vec3 vec: Vector to rotate.

Returns Vec3:

Rotated vector.


setRightVector

This method sets the right basis vector.

void setRightVector(Vec3 vec)

Parameters:

  • Vec3 vec: New right vector.

getRightVector

This method returns the right basis vector.

Vec3 getRightVector()

Returns Vec3:

Right vector.


setUpVector

This method sets the up basis vector.

void setUpVector(Vec3 vec)

Parameters:

  • Vec3 vec: New up vector.

getUpVector

This method returns the up basis vector.

Vec3 getUpVector()

Returns Vec3:

Up vector.


setAtVector

This method sets the forward (at) basis vector.

void setAtVector(Vec3 vec)

Parameters:

  • Vec3 vec: New at vector.

getAtVector

This method returns the forward (at) basis vector.

Vec3 getAtVector()

Returns Vec3:

At vector.


resetRotation

This method resets rotation to identity.

void resetRotation()

extractRotation

This method returns a copy of this matrix with scaling removed.

Mat3 extractRotation()

Returns Mat3:

Rotation-only matrix.


extractScaling

This method extracts scaling factors from the basis vectors.

Vec3 extractScaling()

Returns Vec3:

Scaling factors for x, y and z axes.


postRotateX

This method post-multiplies a rotation around the X axis (degrees).

void postRotateX(number angle_degrees)

Parameters:

  • number angle_degrees: Rotation angle in degrees.

postRotateY

This method post-multiplies a rotation around the Y axis (degrees).

void postRotateY(number angle_degrees)

Parameters:

  • number angle_degrees: Rotation angle in degrees.

postRotateZ

This method post-multiplies a rotation around the Z axis (degrees).

void postRotateZ(number angle_degrees)

Parameters:

  • number angle_degrees: Rotation angle in degrees.

preScale

This method pre-multiplies a scaling transformation.

void preScale(Vec3 scale)

Parameters:

  • Vec3 scale: Scaling factors for x, y and z axes.

postScale

This method post-multiplies a scaling transformation.

void postScale(Vec3 scale)

Parameters:

  • Vec3 scale: Scaling factors for x, y and z axes.

static swap

This method swaps two matrices.

void swap(Mat3 mat1, Mat3 mat2)

Parameters:

  • Mat3 mat1: First matrix.
  • Mat3 mat2: Second matrix.

data

This method returns a pointer to the raw matrix data (column-major float array).

userdata data()

Returns userdata:

Pointer to matrix float data.


Callbacks

No callbacks.