Matrix4x4f
APJS Script API reference for the Matrix4x4f class.
| Type | Name | Interface Description |
|---|---|---|
| Variables | column0: Vector4f | • Function: The first column of the matrix. |
| Variables | column1: Vector4f | • Function: The second column of the matrix. |
| Variables | column2: Vector4f | • Function: The third column of the matrix. |
| Variables | column3: Vector4f | • Function: The fourth column of the matrix. Returns A Vector4f representing the fourth column of the matrix. |
| Functions | constructor() | |
| Functions | 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) | Parameters • • • • • • • • • • • • • • • • |
| Functions | add(other: Matrix4x4f): this | • Function: Performs element-wise addition of another matrix to this matrix. Parameters • Returns This matrix instance after performing the addition operation. |
| Functions | clone(): Matrix4x4f | • Function: Returns a clone of the current Matrix4x4f instance. Returns - A new Matrix4x4f object with the same data as the original. |
| Functions | compose(translation: Vector3f, rotation: Quaternionf, scale: Vector3f): this | • Function: Composes the matrix by setting its translation, rotation, and scale (TRS). Parameters • • • Returns This instance of Matrix4x4f with the applied transformations. |
| Functions | divide(other: Matrix4x4f): this | • Function: Divides each element of the current matrix by the corresponding element of another matrix. Parameters • Returns This matrix after performing the division. |
| Functions | equals(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 • Returns A boolean indicating whether the two matrices are equal. |
| Functions | get(row: number, column: number): number | • Function: Retrieves the value at the specified row and column in the matrix. Parameters • • Returns The value at the specified row and column. |
| Functions | getAxisX(): Vector3f | • Function: Retrieves the X-axis vector from the matrix. Returns - The X-axis vector represented as a 3D vector. |
| Functions | getAxisY(): Vector3f | • Function: Retrieves the Y-axis vector from the matrix. Returns - The Y-axis vector represented as a 3D vector. |
| Functions | getAxisZ(): Vector3f | • Function: Retrieves the Z-axis vector from the matrix. Returns - The Z-axis vector represented as a 3D vector. |
| Functions | getDecompose(translation: Vector3f, rotation: Quaternionf, scale: Vector3f): void | • Function: Decomposes the matrix into its translation, rotation, and scale components. Parameters • • • |
| Functions | getEulerAngles(): Vector3f | • Function: Returns an Euler angle representation of this matrix's rotation. Returns - A vector containing the Euler angles (pitch, yaw, roll) in radians. |
| Functions | inverse(): this | • Function: Computes and sets this matrix to its inverse. Returns This matrix instance after computing the inverse. |
| Functions | multiply(other: Matrix4x4f | number): this | • Function: Multiplies this matrix by another matrix using standard matrix multiplication (this * other). Parameters • Returns This matrix instance after performing the multiplication operation. |
| Functions | multiplyDirection(dir: Vector3f): Vector3f | • Function: Multiplies the given direction vector by this matrix and returns the resulting vector. Parameters • Returns A new Vector3f representing the result of the multiplication. |
| Functions | multiplyPoint(point: Vector3f): Vector3f | • Function: Multiplies the given 3D point by this 4x4 matrix and returns the resulting point. Parameters • Returns A new Vector3f representing the result of the multiplication. |
| Functions | multiplyScalar(scalar: number): this | • Function: Multiplies each element of the matrix by a scalar value. Parameters • Returns This matrix instance after performing the scalar multiplication. |
| Functions | multiplyVector(vec: Vector4f): Vector4f | • Function: Multiplies the given vector by this 4x4 matrix and returns the resulting vector. Parameters • Returns The resulting 4-dimensional vector after multiplication. |
| Functions | scale(vec: Vector3f): this | • Function: Scales the matrix by the components of the given vector. Parameters • Returns The modified Matrix4x4f instance. |
| Functions | set(row: number, column: number, value: number): this | • Function: Sets the value at a specified row and column in the matrix. Parameters • • • Returns This instance of Matrix4x4f for method chaining. |
| Functions | setColumn(col: number, v: Vector4f): this | • Function: Sets the values of a specified column in the matrix. Parameters • • Returns This instance of Matrix4x4f with the updated column values. |
| Functions | setFromToRotation(from: Vector3f, to: Vector3f): this | • Function: Sets the matrix to a rotation that aligns the vector Parameters • • Returns This matrix with the applied rotation. |
| Functions | setIdentity(): this | • Function: Sets this matrix to the identity matrix. Returns This matrix instance after setting it to the identity matrix. |
| Functions | setRow(row: number, v: Vector4f): this | • Function: Sets the values of a specified row in the matrix using a Vector4f. Parameters • • Returns This instance of Matrix4x4f with the updated row values. |
| Functions | setScale(v: Vector3f): this | • Function: Sets this matrix to a scaling matrix using the specified scaling factors. Parameters • Returns This matrix instance after setting it to the scaling matrix. |
| Functions | setTranslate(v: Vector3f): this | • Function: Sets the translation component of the matrix using a Vector3f. Parameters • Returns This instance of Matrix4x4f with the updated translation. |
| Functions | subtract(other: Matrix4x4f): this | • Function: Performs element-wise subtraction of another matrix from this matrix. Parameters • Returns This matrix instance after performing the subtraction operation. |
| Functions | toString(): 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. |
| Functions | translate(vec: Vector3f): this | • Function: Applies a translation to this matrix by multiplying it with a translation matrix. Parameters • Returns This matrix instance after applying the translation transformation. |
| Functions | transpose(): this | • Function: Computes and sets this matrix to its transpose. Returns This matrix instance after computing the transpose. |
| Static Functions | compareApproximately(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 • • • Returns A boolean indicating whether the two matrices are approximately equal within the given tolerance. |
| Static Functions | lookAt(eye: Vector3f, center: Vector3f, up: Vector3f): Matrix4x4f | • Function: Generates a new transformation matrix that orients an object to look at a specified target. Parameters • • • Returns A new Matrix4x4f representing the transformation that orients an object to look from 'eye' towards 'center'. |
| Static Functions | makeFromEulerAngles(euler: Vector3f): Matrix4x4f | • Function: Returns a new 4x4 matrix with the specified Euler angles (in radians). Parameters • Returns A new Matrix4x4f instance constructed from the given Euler angles. |
| Static Functions | makeFromRotation(rotation: Quaternionf): Matrix4x4f | • Function: Returns a new 4x4 matrix with the specified rotation. Parameters • Returns A new Matrix4x4f instance with the applied rotation. |
| Static Functions | makeFromScale(scale: Vector3f): Matrix4x4f | • Function: Returns a new 4x4 matrix with the specified scaling factors. Parameters • Returns A new Matrix4x4f instance with the applied scaling. |
| Static Functions | makeFromTranslation(translation: Vector3f): Matrix4x4f | • Function: Returns a new 4x4 matrix with the specified translation applied. Parameters • Returns A new Matrix4x4f with the given translation. |
| Static Functions | orthographic(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 • • • • • • Returns A new orthographic projection matrix as a Matrix4x4f object. |
| Static Functions | perspective(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 • • • • 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) {
}
}