Matrix3x3f
Type | Name | Interface Description |
---|---|---|
Functions | constructor() | • Function: Create a default 3x3 matrix with all elements initialized to 0. |
Functions | constructor(m0:number,...,m8:number) | • Function: Create a 3x3 matrix with specified element values. |
Functions | set(row: number, column: number, value: number): void | • Function: Sets the specified element of the matrix. |
Functions | get(row: number, column: number): number | • Function: Get the specified element of the matrix. |
Functions | add(other:Matrix3x3f): this | • Function: Adds another matrix to the current matrix. |
Functions | clone(): Matrix3x3f | • Function: Clone the current matrix. |
Functions | divide(other:Matrix3x3f): this | • Function: Divide the current matrix by another matrix. |
Functions | equals(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) {
}
}
Type | Name | Interface Description |
---|---|---|
Functions | inverse(): this | • Function: Find the inverse matrix of the current matrix. |
Functions | multiply(other:Matrix3x3f): this | • Function: Multiply the current matrix by another matrix. |
Functions | multiplyScalar(scalar:number): this | • Function: Multiply the current matrix by a scalar. |
Functions | subtract(other:Matrix3x3f): this | • Function: Subtract another matrix from the current matrix. |
Functions | toString(): string | • Function: Returns the string representation of the current matrix. |
Functions | transpose(): 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) {
}
}