Skip to main content

mat3

Class

A 3x3 matrix type supporting common linear algebra operations.

Index

Example

const identity = new mat3();
console.log('mat3 identity column0:', identity.column0.x, identity.column0.y, identity.column0.z);
console.log('mat3 identity column1:', identity.column1.x, identity.column1.y, identity.column1.z);
console.log('mat3 identity column2:', identity.column2.x, identity.column2.y, identity.column2.z);

const custom = new mat3();
custom.column0 = new vec3(1, 0, 0);
custom.column1 = new vec3(0, 2, 0);
custom.column2 = new vec3(0, 0, 3);
console.log('Scaled mat3 diagonal:', custom.column0.x, custom.column1.y, custom.column2.z);

Constructors

Constructor

new mat3(): mat3

Constructs a new identity mat3 matrix.

Returns

mat3

Properties

column0

column0: vec3

First column vector of the matrix.


column1

column1: vec3

Second column vector of the matrix.


column2

column2: vec3

Third column vector of the matrix.


description

description: string

Human-readable description string for this matrix instance.

Methods

add()

add(mat): mat3

Adds another mat3 to this matrix and returns the result.

Parameters

ParameterType
matmat3

Returns

mat3


determinant()

determinant(): number

Returns the scalar determinant of this matrix.

Returns

number


div()

div(mat): mat3

Divides this matrix by another mat3 element-wise and returns the result.

Parameters

ParameterType
matmat3

Returns

mat3


equal()

equal(mat): boolean

Returns true if this matrix equals the given mat3.

Parameters

ParameterType
matmat3

Returns

boolean


identity()

static identity(): mat3

Returns a mat3 identity matrix.

Returns

mat3


inverse()

inverse(): mat3

Returns the inverse of this matrix.

Returns

mat3


makeFromRotation()

static makeFromRotation(rotation): mat3

Constructs a mat3 rotation matrix from a given angle or rotation value.

Parameters

ParameterType
rotationquat

Returns

mat3


mult()

mult(mat): mat3

Multiplies this matrix by another mat3 and returns the result.

Parameters

ParameterType
matmat3

Returns

mat3


multiplyScalar()

multiplyScalar(scalar): mat3

Multiplies all elements of this matrix by a scalar value and returns the result.

Parameters

ParameterType
scalarnumber

Returns

mat3


sub()

sub(mat): mat3

Subtracts another mat3 from this matrix and returns the result.

Parameters

ParameterType
matmat3

Returns

mat3


toString()

toString(): string

Returns a string representation of this matrix.

Returns

string


transpose()

transpose(): mat3

Returns the transpose of this matrix.

Returns

mat3


zero()

static zero(): mat3

Returns a mat3 with all elements set to zero.

Returns

mat3