mat2
Class2x2 column-major floating-point matrix.
Index
Properties
Methods
Example
const identity = new mat2();
console.log('mat2 identity column0:', identity.column0.x, identity.column0.y);
console.log('mat2 identity column1:', identity.column1.x, identity.column1.y);
const custom = new mat2();
custom.column0 = new vec2(2, 0);
custom.column1 = new vec2(0, 3);
console.log('Custom mat2 column0:', custom.column0.x, custom.column0.y);
console.log('Custom mat2 column1:', custom.column1.x, custom.column1.y);
Constructors
Constructor
new mat2():
mat2
Constructs a new mat2 initialized to the identity matrix.
Returns
mat2
Properties
column0
column0:
vec2
First column of the matrix as a vec2.
column1
column1:
vec2
Second column of the matrix as a vec2.
description
description:
string
Human-readable description string for this matrix instance.
Methods
add()
add(
mat):mat2
Adds another mat2 to this matrix and returns the result.
Parameters
| Parameter | Type |
|---|---|
mat | mat2 |
Returns
mat2
determinant()
determinant():
number
Returns the scalar determinant of this matrix.
Returns
number
div()
div(
mat):mat2
Divides this matrix by another mat2 element-wise and returns the result.
Parameters
| Parameter | Type |
|---|---|
mat | mat2 |
Returns
mat2
equal()
equal(
mat):boolean
Returns true if this matrix equals the given mat2.
Parameters
| Parameter | Type |
|---|---|
mat | mat2 |
Returns
boolean
identity()
staticidentity():mat2
Returns a mat2 set to the identity matrix.
Returns
mat2
inverse()
inverse():
mat2
Returns the inverse of this matrix.
Returns
mat2
mult()
mult(
mat):mat2
Multiplies this matrix by another mat2 and returns the result.
Parameters
| Parameter | Type |
|---|---|
mat | mat2 |
Returns
mat2
multiplyScalar()
multiplyScalar(
scalar):mat2
Multiplies each element of this matrix by a scalar and returns the result.
Parameters
| Parameter | Type |
|---|---|
scalar | number |
Returns
mat2
sub()
sub(
mat):mat2
Subtracts another mat2 from this matrix and returns the result.
Parameters
| Parameter | Type |
|---|---|
mat | mat2 |
Returns
mat2
toString()
toString():
string
Returns a string representation of this matrix.
Returns
string
transpose()
transpose():
mat2
Returns the transpose of this matrix.
Returns
mat2
zero()
staticzero():mat2
Returns a mat2 with all elements set to zero.
Returns
mat2