Skip to main content

Matrix3x3f

TypeNameInterface Description
Functionsconstructor()

Function: Create a default 3x3 matrix with all elements initialized to 0.

Functionsconstructor(m0:number,...,m8:number)

Function: Create a 3x3 matrix with specified element values.

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

Function: Sets the specified element of the matrix.

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

Function: Get the specified element of the matrix.

Functionsadd(other:Matrix3x3f): this

Function: Adds another matrix to the current matrix.

Functionsclone(): Matrix3x3f

Function: Clone the current matrix.

Functionsdivide(other:Matrix3x3f): this

Function: Divide the current matrix by another matrix.

Functionsequals(other: Matrix3x3f): boolean

Function: Checks whether the current matrix is equal to another matrix.

Examples

constructor()

let mat = new Matrix3x3f();

constructor(m0:number,....m8:number)

let mat = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);

set(row: number, column: number, value: number): void

let mat = new Matrix3x3f();
mat.set(0, 0, 1);

get(row: number, column: number): number

let mat = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
let value = mat.get(0, 0);
console.log(value); // 1

add(other:Matrix3x3f): this

let mat1 = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat2 = new Matrix3x3f(9, 8, 7, 6, 5, 4, 3, 2, 1);
mat1.add(mat2);

clone(): Matrix3x3f

let mat = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
let cloneMat = mat.clone();

divide(other:Matrix3x3f): this

let mat1 = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat2 = new Matrix3x3f(9, 8, 7, 6, 5, 4, 3, 2, 1);
mat1.divide(mat2);

equals(other: Matrix3x3f): boolean

let mat1 = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat2 = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
console.log(mat1.equals(mat2)); // true

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

onStart() {
let mat = new Matrix3x3f();
mat.set(0, 0, 1);
let mat2 = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
mat2.get(0,0);

//add
mat1.add(mat2);

//devide
mat1.divide(mat2);

//clone
const clonedMat = mat1.clone();

//equals
console.log(mat1.equals(clonedMat));


}
onUpdate(deltaTime: number) {
}
}
TypeNameInterface Description
Functionsinverse(): this

Function: Find the inverse matrix of the current matrix.

Functionsmultiply(other:Matrix3x3f): this

Function: Multiply the current matrix by another matrix.

FunctionsmultiplyScalar(scalar:number): this

Function: Multiply the current matrix by a scalar.

Functionssubtract(other:Matrix3x3f): this

Function: Subtract another matrix from the current matrix.

FunctionstoString(): string

Function: Returns the string representation of the current matrix.

Functionstranspose(): this

Function: Transpose the current matrix.

Examples

inverse(): this

let mat = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
mat.inverse();

multiply(other:Matrix3x3f): this

let mat1 = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat2 = new Matrix3x3f(9, 8, 7, 6, 5, 4, 3, 2, 1);
mat1.multiply(mat2);

multiplyScalar(scalar:number): this

let mat = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
mat.multiplyScalar(2);

subtract(other:Matrix3x3f): this

let mat1 = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
let mat2 = new Matrix3x3f(9, 8, 7, 6, 5, 4, 3, 2, 1);
mat1.subtract(mat2);

toString(): string

let mat = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
console.log(mat.toString()); // "Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9)"

transpose(): this

let mat = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);
mat.transpose();

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {

onStart() {
let mat = new Matrix3x3f();
mat.set(0, 0, 1);
let mat2 = new Matrix3x3f(1, 2, 3, 4, 5, 6, 7, 8, 9);


//inverse
mat1.inverse();

//multiply
mat1.multiply(mat2);

//multiplyScalar
mat1.multiplyScalar(2);

//subtract
mat1.subtract(mat2);


//transpose
mat1.transpose();

//toString
console.log(mat1.toString())


}
onUpdate(deltaTime: number) {
}
}
Copyright © 2025 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalCookies