Skip to main content

Matrix4x4f

APJS Script API reference for the Matrix4x4f class.

TypeNameInterface Description
Variablescolumn0: Vector4f

Function: The first column of the matrix.

Variablescolumn1: Vector4f

Function: The second column of the matrix.

Variablescolumn2: Vector4f

Function: The third column of the matrix.

Variablescolumn3: Vector4f

Function: The fourth column of the matrix.

Returns A Vector4f representing the fourth column of the matrix.

Functionsconstructor()

Functionsconstructor(m0?: number, m1?: number, m2?: number, m3?: number, m4?: number, m5?: number, m6?: number, m7?: number, m8?: number, m9?: number, m10?: number, m11?: number, m12?: number, m13?: number, m14?: number, m15?: number)

Parameters

m0: - Value at row 0, column 0 of the matrix.

m1: - Value at row 0, column 1 of the matrix.

m2: - Value at row 0, column 2 of the matrix.

m3: - Value at row 0, column 3 of the matrix.

m4: - Value at row 1, column 0 of the matrix.

m5: - Value at row 1, column 1 of the matrix.

m6: - Value at row 1, column 2 of the matrix.

m7: - Value at row 1, column 3 of the matrix.

m8: - Value at row 2, column 0 of the matrix.

m9: - Value at row 2, column 1 of the matrix.

m10: - Value at row 2, column 2 of the matrix.

m11: - Value at row 2, column 3 of the matrix.

m12: - Value at row 3, column 0 of the matrix.

m13: - Value at row 3, column 1 of the matrix.

m14: - Value at row 3, column 2 of the matrix.

m15: - Value at row 3, column 3 of the matrix.

Functionsadd(other: Matrix4x4f): this

Function: Performs element-wise addition of another matrix to this matrix.

Parameters

other: - The matrix to add to this matrix.

Returns This matrix instance after performing the addition operation.

Functionsclone(): Matrix4x4f

Function: Returns a clone of the current Matrix4x4f instance.

Returns - A new Matrix4x4f object with the same data as the original.

Functionscompose(translation: Vector3f, rotation: Quaternionf, scale: Vector3f): this

Function: Composes the matrix by setting its translation, rotation, and scale (TRS).

Parameters

translation: - The translation vector to apply.

rotation: - The quaternion representing the rotation to apply.

scale: - The scaling vector to apply.

Returns This instance of Matrix4x4f with the applied transformations.

Functionsdivide(other: Matrix4x4f): this

Function: Divides each element of the current matrix by the corresponding element of another matrix.

Parameters

other: - The matrix to divide by.

Returns This matrix after performing the division.

Functionsequals(other: Matrix4x4f): boolean

Function: Compares this matrix with another matrix for equality. This method performs a direct value comparison of the elements in both matrices.

Parameters

other: - The Matrix4x4f object to compare with this matrix.

Returns A boolean indicating whether the two matrices are equal.

Functionsget(row: number, column: number): number

Function: Retrieves the value at the specified row and column in the matrix.

Parameters

row: - The row index of the desired element (0-based).

column: - The column index of the desired element (0-based).

Returns The value at the specified row and column.

FunctionsgetAxisX(): Vector3f

Function: Retrieves the X-axis vector from the matrix.

Returns - The X-axis vector represented as a 3D vector.

FunctionsgetAxisY(): Vector3f

Function: Retrieves the Y-axis vector from the matrix.

Returns - The Y-axis vector represented as a 3D vector.

FunctionsgetAxisZ(): Vector3f

Function: Retrieves the Z-axis vector from the matrix.

Returns - The Z-axis vector represented as a 3D vector.

FunctionsgetDecompose(translation: Vector3f, rotation: Quaternionf, scale: Vector3f): void

Function: Decomposes the matrix into its translation, rotation, and scale components.

Parameters

translation: - The vector to store the translation component.

rotation: - The quaternion to store the rotation component.

scale: - The vector to store the scale component.

FunctionsgetEulerAngles(): Vector3f

Function: Returns an Euler angle representation of this matrix's rotation.

Returns - A vector containing the Euler angles (pitch, yaw, roll) in radians.

Functionsinverse(): this

Function: Computes and sets this matrix to its inverse.

Returns This matrix instance after computing the inverse.

Functionsmultiply(other: Matrix4x4f | number): this

Function: Multiplies this matrix by another matrix using standard matrix multiplication (this * other).

Parameters

other: - The matrix to multiply this matrix by.

Returns This matrix instance after performing the multiplication operation.

FunctionsmultiplyDirection(dir: Vector3f): Vector3f

Function: Multiplies the given direction vector by this matrix and returns the resulting vector.

Parameters

dir: - The direction vector to be multiplied.

Returns A new Vector3f representing the result of the multiplication.

FunctionsmultiplyPoint(point: Vector3f): Vector3f

Function: Multiplies the given 3D point by this 4x4 matrix and returns the resulting point.

Parameters

point: - The 3D point to be multiplied by the matrix.

Returns A new Vector3f representing the result of the multiplication.

FunctionsmultiplyScalar(scalar: number): this

Function: Multiplies each element of the matrix by a scalar value.

Parameters

scalar: - The scalar value to multiply each element of the matrix by.

Returns This matrix instance after performing the scalar multiplication.

FunctionsmultiplyVector(vec: Vector4f): Vector4f

Function: Multiplies the given vector by this 4x4 matrix and returns the resulting vector.

Parameters

vec: - A 4-dimensional vector (Vector4f) to be multiplied by the matrix.

Returns The resulting 4-dimensional vector after multiplication.

Functionsscale(vec: Vector3f): this

Function: Scales the matrix by the components of the given vector.

Parameters

vec: - A Vector3f object representing the scaling factors along each axis.

Returns The modified Matrix4x4f instance.

Functionsset(row: number, column: number, value: number): this

Function: Sets the value at a specified row and column in the matrix.

Parameters

row: - The row index (0-based).

column: - The column index (0-based).

value: - The value to set at the specified position.

Returns This instance of Matrix4x4f for method chaining.

FunctionssetColumn(col: number, v: Vector4f): this

Function: Sets the values of a specified column in the matrix.

Parameters

col: - The index of the column to set (0-3).

v: - A Vector4f object containing the new values for the column (r0, r1, r2, r3).

Returns This instance of Matrix4x4f with the updated column values.

FunctionssetFromToRotation(from: Vector3f, to: Vector3f): this

Function: Sets the matrix to a rotation that aligns the vector from to the vector to.

Parameters

from: - The initial vector.

to: - The target vector.

Returns This matrix with the applied rotation.

FunctionssetIdentity(): this

Function: Sets this matrix to the identity matrix.

Returns This matrix instance after setting it to the identity matrix.

FunctionssetRow(row: number, v: Vector4f): this

Function: Sets the values of a specified row in the matrix using a Vector4f.

Parameters

row: - The index of the row to set [0-3].

v: - A Vector4f containing the values (c0, c1, c2, c3) for the row.

Returns This instance of Matrix4x4f with the updated row values.

FunctionssetScale(v: Vector3f): this

Function: Sets this matrix to a scaling matrix using the specified scaling factors.

Parameters

v: - A Vector3f representing the scaling factors along the x, y, and z axes.

Returns This matrix instance after setting it to the scaling matrix.

FunctionssetTranslate(v: Vector3f): this

Function: Sets the translation component of the matrix using a Vector3f.

Parameters

v: - The translation vector to be applied.

Returns This instance of Matrix4x4f with the updated translation.

Functionssubtract(other: Matrix4x4f): this

Function: Performs element-wise subtraction of another matrix from this matrix.

Parameters

other: - The matrix to subtract from this matrix.

Returns This matrix instance after performing the subtraction operation.

FunctionstoString(): string

Function: Returns a formatted string representation of the matrix showing all 16 elements.

Returns A string representation of the matrix with elements arranged in a 4x4 grid.

Functionstranslate(vec: Vector3f): this

Function: Applies a translation to this matrix by multiplying it with a translation matrix.

Parameters

vec: - The translation vector to apply to this matrix.

Returns This matrix instance after applying the translation transformation.

Functionstranspose(): this

Function: Computes and sets this matrix to its transpose.

Returns This matrix instance after computing the transpose.

Static FunctionscompareApproximately(mat1: Matrix4x4f, mat2: Matrix4x4f, dist: number): boolean

Function: Approximate comparison of the two Matrix4x4f matrices by comparing the value of each dimension with a specified tolerance.

Parameters

mat1: - The first Matrix4x4f to compare.

mat2: - The second Matrix4x4f to compare.

dist: - The tolerance value for comparison.

Returns A boolean indicating whether the two matrices are approximately equal within the given tolerance.

Static FunctionslookAt(eye: Vector3f, center: Vector3f, up: Vector3f): Matrix4x4f

Function: Generates a new transformation matrix that orients an object to look at a specified target.

Parameters

eye: - The position of the viewer/camera.

center: - The position of the target to look at.

up: - The upward direction in the world, typically (0, 1, 0).

Returns A new Matrix4x4f representing the transformation that orients an object to look from 'eye' towards 'center'.

Static FunctionsmakeFromEulerAngles(euler: Vector3f): Matrix4x4f

Function: Returns a new 4x4 matrix with the specified Euler angles (in radians).

Parameters

euler: - A Vector3f representing the Euler angles.

Returns A new Matrix4x4f instance constructed from the given Euler angles.

Static FunctionsmakeFromRotation(rotation: Quaternionf): Matrix4x4f

Function: Returns a new 4x4 matrix with the specified rotation.

Parameters

rotation: - A Quaternionf representing the desired rotation.

Returns A new Matrix4x4f instance with the applied rotation.

Static FunctionsmakeFromScale(scale: Vector3f): Matrix4x4f

Function: Returns a new 4x4 matrix with the specified scaling factors.

Parameters

scale: - A Vector3f representing the scaling factors along the x, y, and z axes.

Returns A new Matrix4x4f instance with the applied scaling.

Static FunctionsmakeFromTranslation(translation: Vector3f): Matrix4x4f

Function: Returns a new 4x4 matrix with the specified translation applied.

Parameters

translation: - A Vector3f representing the translation to apply.

Returns A new Matrix4x4f with the given translation.

Static Functionsorthographic(left: number, right: number, bottom: number, top: number, zNear: number, zFar: number): Matrix4x4f

Function: Generates a new orthographic projection matrix using the provided arguments.

Parameters

left: - The coordinate for the left vertical clipping plane.

right: - The coordinate for the right vertical clipping plane.

bottom: - The coordinate for the bottom horizontal clipping plane.

top: - The coordinate for the top horizontal clipping plane.

zNear: - The distance to the near depth clipping plane. This value is negative if the plane is behind the viewer.

zFar: - The distance to the far depth clipping plane. This value is negative if the plane is behind the viewer.

Returns A new orthographic projection matrix as a Matrix4x4f object.

Static Functionsperspective(fovY: number, aspect: number, zNear: number, zFar: number): Matrix4x4f

Function: Generates a perspective projection matrix using the provided field of view, aspect ratio, and near/far clipping planes.

Parameters

fovY: - The vertical field of view angle in degrees.

aspect: - The aspect ratio (width divided by height) of the viewport.

zNear: - The distance to the near clipping plane.

zFar: - The distance to the far clipping plane.

Returns A new Matrix4x4f representing the perspective projection matrix.

Examples

constructor()

let obj = new APJS.Matrix4x4f();

constructor(m0?: number, m1?: number, m2?: number, m3?: number, m4?: number, m5?: number, m6?: number, m7?: number, m8?: number, m9?: number, m10?: number, m11?: number, m12?: number, m13?: number, m14?: number, m15?: number)

let obj = new APJS.Matrix4x4f();

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
// TODO: instantiate / use Matrix4x4f here
}
onUpdate(deltaTime: number) {
}
}
Copyright © 2026 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalTerms of ServicePrivacy PolicyCookies