Skip to content

class Mat3 (shared-side)

Available since version: 0.3.0

3x3 matrix with common transformation utilities.

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

Resets the matrix to identity.

void makeIdentity()

makeZero

Sets all matrix elements to zero.

void makeZero()

makeOrthonormal

Orthonormalizes the matrix basis vectors.

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

void makeOrthonormal()

isUpper3x3Orthonormal

Returns true if the matrix basis vectors are orthonormal.

bool isUpper3x3Orthonormal()

Returns bool:

True if orthonormal within epsilon tolerance.


transpose

Returns the transposed matrix.

Mat3 transpose()

Returns Mat3:

Transposed matrix.


inverse

Returns the inverse matrix.

Mat3 inverse()

Returns Mat3:

Inverse matrix.


rotate

Rotates a vector by this matrix.

Vec3 rotate(Vec3 vec)

Parameters:

  • Vec3 vec: Vector to rotate.

Returns Vec3:

Rotated vector.


setRightVector

Sets the right basis vector.

void setRightVector(Vec3 vec)

Parameters:

  • Vec3 vec: New right vector.

getRightVector

Returns the right basis vector.

Vec3 getRightVector()

Returns Vec3:

Right vector.


setUpVector

Sets the up basis vector.

void setUpVector(Vec3 vec)

Parameters:

  • Vec3 vec: New up vector.

getUpVector

Returns the up basis vector.

Vec3 getUpVector()

Returns Vec3:

Up vector.


setAtVector

Sets the forward (at) basis vector.

void setAtVector(Vec3 vec)

Parameters:

  • Vec3 vec: New at vector.

getAtVector

Returns the forward (at) basis vector.

Vec3 getAtVector()

Returns Vec3:

At vector.


resetRotation

Resets rotation to identity.

void resetRotation()

extractRotation

Returns a copy of this matrix with scaling removed.

Mat3 extractRotation()

Returns Mat3:

Rotation-only matrix.


extractScaling

Extracts scaling factors from the basis vectors.

Vec3 extractScaling()

Returns Vec3:

Scaling factors for x, y and z axes.


postRotateX

Post-multiplies a rotation around the X axis (degrees).

void postRotateX(number angle_degrees)

Parameters:

  • number angle_degrees: Rotation angle in degrees.

postRotateY

Post-multiplies a rotation around the Y axis (degrees).

void postRotateY(number angle_degrees)

Parameters:

  • number angle_degrees: Rotation angle in degrees.

postRotateZ

Post-multiplies a rotation around the Z axis (degrees).

void postRotateZ(number angle_degrees)

Parameters:

  • number angle_degrees: Rotation angle in degrees.

preScale

Pre-multiplies a scaling transformation.

void preScale(Vec3 scale)

Parameters:

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

postScale

Post-multiplies a scaling transformation.

void postScale(Vec3 scale)

Parameters:

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

static swap

Swaps two matrices.

void swap(Mat3 mat1, Mat3 mat2)

Parameters:

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

data

Returns a pointer to the raw matrix data (column-major float array).

userdata data()

Returns userdata:

Pointer to matrix float data.


Callbacks

No callbacks.