Skip to content

Documentation / base / Matrix4x4

Class: Matrix4x4 ​

Defined in: libs/base/src/math/vector.ts:3396

4x4 Matrix

Remarks ​

The matrix is column-major: | m00, m10, m20, m30 | | m01, m11, m21, m31 | | m02, m12, m22, m32 | | m03, m13, m23, m33 |

Extends ​

Indexable ​

[index: number]: number

Constructors ​

Constructor ​

new Matrix4x4(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3416

Creates a Matrix4x4 initialized with values.

Parameters ​

m00 ​

number

element at row 0, column 0

m10 ​

number

element at row 0, column 1

m20 ​

number

element at row 0, column 2

m30 ​

number

element at row 0, column 3

m01 ​

number

element at row 1, column 0

m11 ​

number

element at row 1, column 1

m21 ​

number

element at row 1, column 2

m31 ​

number

element at row 1, column 3

m02 ​

number

element at row 2, column 0

m12 ​

number

element at row 2, column 1

m22 ​

number

element at row 2, column 2

m32 ​

number

element at row 2, column 3

m03 ​

number

element at row 3, column 0

m13 ​

number

element at row 3, column 1

m23 ​

number

element at row 3, column 2

m33 ​

number

element at row 3, column 3

Returns ​

Matrix4x4

Overrides ​

VectorBase.constructor

Constructor ​

new Matrix4x4(elements): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3438

Creates a Matrix4x4 initialized with values in an array.

Parameters ​

elements ​

number[]

Array that contains the values.

Returns ​

Matrix4x4

Overrides ​

VectorBase.constructor

Constructor ​

new Matrix4x4(array): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3443

Cerates a Matrix4x4 initialized with values in a Float32Array.

Parameters ​

array ​

Float32Array

Float32Array object that contains the values.

Returns ​

Matrix4x4

Overrides ​

VectorBase.constructor

Constructor ​

new Matrix4x4(buffer, offset): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3449

Creates a new Matrix4x4 placed on a given ArrayBuffer object.

Parameters ​

buffer ​

ArrayBuffer

The array buffer object.

offset ​

number

The byte offset of the buffer where the matrix placed at.

Returns ​

Matrix4x4

Overrides ​

VectorBase.constructor

Constructor ​

new Matrix4x4(): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3453

Creates a new identity Matrix4x4.

Returns ​

Matrix4x4

Overrides ​

VectorBase.constructor

Accessors ​

m00 ​

Get Signature ​

get m00(): number

Defined in: libs/base/src/math/vector.ts:3529

Get the element at row 0, column 0

Returns ​

number

Set Signature ​

set m00(v): void

Defined in: libs/base/src/math/vector.ts:3532

Parameters ​
v ​

number

Returns ​

void


m10 ​

Get Signature ​

get m10(): number

Defined in: libs/base/src/math/vector.ts:3536

Get the element at row 0, column 1

Returns ​

number

Set Signature ​

set m10(v): void

Defined in: libs/base/src/math/vector.ts:3539

Parameters ​
v ​

number

Returns ​

void


m20 ​

Get Signature ​

get m20(): number

Defined in: libs/base/src/math/vector.ts:3543

Get the element at row 0, column 2

Returns ​

number

Set Signature ​

set m20(v): void

Defined in: libs/base/src/math/vector.ts:3546

Parameters ​
v ​

number

Returns ​

void


m30 ​

Get Signature ​

get m30(): number

Defined in: libs/base/src/math/vector.ts:3550

Get the element at row 0, column 3

Returns ​

number

Set Signature ​

set m30(v): void

Defined in: libs/base/src/math/vector.ts:3553

Parameters ​
v ​

number

Returns ​

void


m01 ​

Get Signature ​

get m01(): number

Defined in: libs/base/src/math/vector.ts:3557

Get the element at row 1, column 0

Returns ​

number

Set Signature ​

set m01(v): void

Defined in: libs/base/src/math/vector.ts:3560

Parameters ​
v ​

number

Returns ​

void


m11 ​

Get Signature ​

get m11(): number

Defined in: libs/base/src/math/vector.ts:3564

Get the element at row 1, column 1

Returns ​

number

Set Signature ​

set m11(v): void

Defined in: libs/base/src/math/vector.ts:3567

Parameters ​
v ​

number

Returns ​

void


m21 ​

Get Signature ​

get m21(): number

Defined in: libs/base/src/math/vector.ts:3571

Get the element at row 1, column 2

Returns ​

number

Set Signature ​

set m21(v): void

Defined in: libs/base/src/math/vector.ts:3574

Parameters ​
v ​

number

Returns ​

void


m31 ​

Get Signature ​

get m31(): number

Defined in: libs/base/src/math/vector.ts:3578

Get the element at row 1, column 3

Returns ​

number

Set Signature ​

set m31(v): void

Defined in: libs/base/src/math/vector.ts:3581

Parameters ​
v ​

number

Returns ​

void


m02 ​

Get Signature ​

get m02(): number

Defined in: libs/base/src/math/vector.ts:3585

Get the element at row 2, column 0

Returns ​

number

Set Signature ​

set m02(v): void

Defined in: libs/base/src/math/vector.ts:3588

Parameters ​
v ​

number

Returns ​

void


m12 ​

Get Signature ​

get m12(): number

Defined in: libs/base/src/math/vector.ts:3592

Get the element at row 2, column 1

Returns ​

number

Set Signature ​

set m12(v): void

Defined in: libs/base/src/math/vector.ts:3595

Parameters ​
v ​

number

Returns ​

void


m22 ​

Get Signature ​

get m22(): number

Defined in: libs/base/src/math/vector.ts:3599

Get the element at row 2, column 2

Returns ​

number

Set Signature ​

set m22(v): void

Defined in: libs/base/src/math/vector.ts:3602

Parameters ​
v ​

number

Returns ​

void


m32 ​

Get Signature ​

get m32(): number

Defined in: libs/base/src/math/vector.ts:3606

Get the element at row 2, column 3

Returns ​

number

Set Signature ​

set m32(v): void

Defined in: libs/base/src/math/vector.ts:3609

Parameters ​
v ​

number

Returns ​

void


m03 ​

Get Signature ​

get m03(): number

Defined in: libs/base/src/math/vector.ts:3613

Get the element at row 3, column 0

Returns ​

number

Set Signature ​

set m03(v): void

Defined in: libs/base/src/math/vector.ts:3616

Parameters ​
v ​

number

Returns ​

void


m13 ​

Get Signature ​

get m13(): number

Defined in: libs/base/src/math/vector.ts:3620

Get the element at row 3, column 1

Returns ​

number

Set Signature ​

set m13(v): void

Defined in: libs/base/src/math/vector.ts:3623

Parameters ​
v ​

number

Returns ​

void


m23 ​

Get Signature ​

get m23(): number

Defined in: libs/base/src/math/vector.ts:3627

Get the element at row 3, column 2

Returns ​

number

Set Signature ​

set m23(v): void

Defined in: libs/base/src/math/vector.ts:3630

Parameters ​
v ​

number

Returns ​

void


m33 ​

Get Signature ​

get m33(): number

Defined in: libs/base/src/math/vector.ts:3634

Get the element at row 3, column 3

Returns ​

number

Set Signature ​

set m33(v): void

Defined in: libs/base/src/math/vector.ts:3637

Parameters ​
v ​

number

Returns ​

void

Methods ​

equalsTo() ​

equalsTo(other, epsl?): boolean

Defined in: libs/base/src/math/vector.ts:32

Check if all data is close enough to another

Parameters ​

other ​

Float32Array<ArrayBuffer>

The data to be compared with.

epsl? ​

number

Returns ​

boolean

true if close enough, otherwise false.

Inherited from ​

VectorBase.equalsTo


toString() ​

toString(): string

Defined in: libs/base/src/math/vector.ts:52

Convert this to string object.

Returns ​

string

Inherited from ​

VectorBase.toString


isNaN() ​

isNaN(): boolean

Defined in: libs/base/src/math/vector.ts:61

Check the data for the presence of NaN.

Returns ​

boolean

true if NaN is present, otherwise false.

Inherited from ​

VectorBase.isNaN


setRandom() ​

setRandom(minValue, maxValue): void

Defined in: libs/base/src/math/vector.ts:75

Generate random vector

Parameters ​

minValue ​

number

Minimum value of any component of the vector

maxValue ​

number

Maximum value of any component of the vector

Returns ​

void

Inherited from ​

VectorBase.setRandom


clone() ​

clone(): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3525

Creates a new Matrix4x4 initialized with values from this matrix.

Returns ​

Matrix4x4

The new matrix.


getRow() ​

getRow(row, result?): Vector4

Defined in: libs/base/src/math/vector.ts:3646

Get the values in a row as a Vector4

Parameters ​

row ​

number

The row index

result? ​

Vector4

The output vector, if not specified, a new vector will be created.

Returns ​

Vector4

The output vector


setRow() ​

setRow(row, v): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3660

Set values to a row in the matrix.

Parameters ​

row ​

number

The row index

v ​

Vector4

The values to be set

Returns ​

Matrix4x4

  • self

setRowXYZW() ​

setRowXYZW(row, x, y, z, w): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3676

Set values to a row in the matrix.

Parameters ​

row ​

number

The row index

x ​

number

The first value of the row to be set

y ​

number

The second value of the row to be set

z ​

number

The third value of the row to be set

w ​

number

The fourth value of the row to be set

Returns ​

Matrix4x4

  • self

getCol() ​

getCol(col, result?): Vector4

Defined in: libs/base/src/math/vector.ts:3689

Get the values in a column as a Vector4

Parameters ​

col ​

number

The column index

result? ​

Vector4

The output vector, if not specified, a new vector will be created.

Returns ​

Vector4

The output vector


setCol() ​

setCol(col, v): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3698

Set values to a column in the matrix.

Parameters ​

col ​

number

The column index.

v ​

Vector4

The values to be set.

Returns ​

Matrix4x4

self


setColXYZW() ​

setColXYZW(col, x, y, z, w): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3714

Set values to a column in the matrix.

Parameters ​

col ​

number

The column index.

x ​

number

The first value of the column to be set.

y ​

number

The second value of the column to be set.

z ​

number

The third value of the column to be set.

w ​

number

The fourth value of the column to be set.

Returns ​

Matrix4x4

self


add() ​

static add(a, b, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3728

Adds two Matrix4x4's component-wise.

Parameters ​

a ​

Matrix4x4

The first operand.

b ​

Matrix4x4

The second operand.

result? ​

Matrix4x4

The output matrix (can be the same as a or b), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


sub() ​

static sub(a, b, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3742

Subtracts two Matrix4x4's component-wise.

Parameters ​

a ​

Matrix4x4

The first operand.

b ​

Matrix4x4

The second operand.

result? ​

Matrix4x4

The output matrix (can be the same as a or b), if not specified, a new matrix will be created.

Returns ​

Matrix4x4


mul() ​

static mul(a, b, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3756

Multiplys two Matrix4x4's component-wise.

Parameters ​

a ​

Matrix4x4

The first operand.

b ​

Matrix4x4

The second operand.

result? ​

Matrix4x4

The output matrix (can be the same as a or b), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


div() ​

static div(a, b, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3770

Divides two Matrix4x4's component-wise.

Parameters ​

a ​

Matrix4x4

The first operand.

b ​

Matrix4x4

The second operand.

result? ​

Matrix4x4

The output matrix (can be the same as a or b), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


scale() ​

static scale(a, f, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3784

Scales a Matrix4x4 by a scalar number component-wise.

Parameters ​

a ​

Matrix4x4

The matrix to be scaled.

f ​

number

The scalar number.

result? ​

Matrix4x4

The output matrix (can be the same as a), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


identity() ​

static identity(result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3796

Creates an identity Matrix4x4.

Parameters ​

result? ​

Matrix4x4

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


ortho() ​

static ortho(left, right, bottom, top, near, far, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3812

Creates an orthogonal projection matrix from a given frustum.

Parameters ​

left ​

number

Left bound of the frustum.

number

Right bound of the frustum.

bottom ​

number

Bottom bound of the frustum.

top ​

number

Top bound of the frustum.

near ​

number

Near bound of the frustum.

far ​

number

Far bound of the frustum.

result? ​

Matrix4x4

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


reflection() ​

static reflection(nx, ny, nz, d, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3856

Creates a reflection matrix from a plane.

Parameters ​

nx ​

number

The x component of the plane normal.

ny ​

number

The y component of the plane normal.

nz ​

number

The z component of the plane normal.

d ​

number

The plane distance.

result? ​

Matrix4x4

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


perspective() ​

static perspective(fovY, aspect, znear, zfar, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3885

Creates a right-handed perspective projection matrix.

Parameters ​

fovY ​

number

The vertical field of view in radians.

aspect ​

number

The aspect ratio.

znear ​

number

The near clip plane.

zfar ​

number

The far clip plane.

result? ​

Matrix4x4

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


obliqueProjection() ​

static obliqueProjection(projectionMatrix, clipPlane): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3890

Parameters ​

projectionMatrix ​

Matrix4x4

clipPlane ​

Plane

Returns ​

Matrix4x4


obliquePerspective() ​

static obliquePerspective(perspectiveMatrix, nearPlane): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3907

Parameters ​

perspectiveMatrix ​

Matrix4x4

nearPlane ​

Vector4

Returns ​

Matrix4x4


frustum() ​

static frustum(left, right, bottom, top, znear, zfar, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:3969

Creates a perspective projection matrix from a frustum.

Parameters ​

left ​

number

Left bound of the frustum.

right ​

number

Right bound of the frustum.

bottom ​

number

Bottom bound of the frustum.

top ​

number

Top bound of the frustum.

znear ​

number

Near bound of the frustum.

zfar ​

number

Far bound of the frustum.

result? ​

Matrix4x4

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


transpose() ​

static transpose(matrix, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4014

Transpose a Matrix4x4.

Parameters ​

matrix ​

Matrix4x4

The matrix to be transposed.

result? ​

Matrix4x4

The output matrix (can be the same as matrix), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


invert() ​

static invert(matrix, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4049

Inverts a Matrix4x4

Parameters ​

matrix ​

Matrix4x4

The matrix to be inverted.

result? ​

Matrix4x4

The output matrix (can be the same as matrix). if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


invertAffine() ​

static invertAffine(matrix, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4132

Inverts a Matrix4x4 which presents an affine transformation.

Parameters ​

matrix ​

Matrix4x4

The matrix to be inverted.

result? ​

Matrix4x4

The output matrix (can be the same as matrix). if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


translation() ​

static translation(t, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4190

Creates a Matrix4x4 which presents a translation.

Parameters ​

t ​

Vector3

The translate vector.

result? ​

Matrix4x4

The output matrix. if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


translationXYZ() ​

static translationXYZ(tx, ty, tz, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4219

Creates a Matrix4x4 which presents a translation.

Parameters ​

tx ​

number

The translate of x axis.

ty ​

number

The translate of y axis.

tz ​

number

The translate of z axis.

result? ​

Matrix4x4

The output matrix. if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


scaling() ​

static scaling(s, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4246

Creates a Matrix4x4 which presents a scaling.

Parameters ​

s ​

Vector3

The scale vector.

result? ​

Matrix4x4

The output matrix. if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


scalingXYZ() ​

static scalingXYZ(sx, sy, sz, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4275

Creates a Matrix4x4 which presents a scaling.

Parameters ​

sx ​

number

The scale of x axis.

sy ​

number

The scale of y axis.

sz ​

number

The scale of z axis.

result? ​

Matrix4x4

The output matrix. if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


rotationX() ​

static rotationX(angle, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4302

Creates a Matrix4x4 which presents a rotation around the x axis.

Parameters ​

angle ​

number

The rotate angle in radians.

result? ​

Matrix4x4

The output matrix. if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


rotationY() ​

static rotationY(angle, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4331

Creates a Matrix4x4 which presents a rotation around the y axis.

Parameters ​

angle ​

number

The rotate angle in radians.

result? ​

Matrix4x4

The output matrix. if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


rotationZ() ​

static rotationZ(angle, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4360

Creates a Matrix4x4 which presents a rotation around the z axis.

Parameters ​

angle ​

number

The rotate angle in radians.

result? ​

Matrix4x4

The output matrix. if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


rotation() ​

static rotation(axis, angle, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4390

Creates a Matrix4x4 which presents a rotation around a given axis.

Parameters ​

axis ​

Vector3

The axis vector.

angle ​

number

The rotate angle in radians.

result? ​

Matrix4x4

The output matrix. if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


compose() ​

static compose(scale, rotation, translation, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4431

Compose matrix from rotation, translation and scale components.

Parameters ​

scale ​

Vector3

The input scale vector.

rotation ​

Quaternion | Matrix3x3 | Matrix4x4

The input rotation matrix or quaternion.

translation ​

Vector3

The input translation vector.

result? ​

Matrix4x4

Returns ​

Matrix4x4

The composed matrix


lookAt() ​

static lookAt(eye, target, up, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4448

Creates a look-at matrix.

Parameters ​

eye ​

Vector3

Position of the eye.

target ​

Vector3

The point that the eye is looking at.

up ​

Vector3

The up vector.

result? ​

Matrix4x4

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


lookAtCubeFace() ​

static lookAtCubeFace(face, pos, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4478

Creates a matrix, which presents a transform of looking at given cube face.

Parameters ​

face ​

CubeFace

The cube face to be looked at.

pos ​

Vector3

result? ​

Matrix4x4

The output matrix, if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


multiply() ​

static multiply(m1, m2, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4503

Multiplies two Matrix4x4's

Parameters ​

m1 ​

Matrix4x4

The first operand.

m2 ​

Matrix4x4

The second operand.

result? ​

Matrix4x4

The output matrix (can be the same as m1 or m2), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


multiplyAffine() ​

static multiplyAffine(m1, m2, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4564

Multiplies two Matrix4x4's which present affine transformations.

Parameters ​

m1 ​

Matrix4x4

The first operand.

m2 ​

Matrix4x4

The second operand.

result? ​

Matrix4x4

The output matrix (can be the same as m1 or m2), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix


translateRight() ​

static translateRight(m, t, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4621

Post-translate a Matrix4x4 by a vector.

Parameters ​

m ​

Matrix4x4

The matrix that will be translated.

t ​

Vector3

The translate vector.

result? ​

Matrix4x4

The output matrix (can be the same as m), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix

Remarks ​

result = m * (translate matrix for t)


translateLeft() ​

static translateLeft(m, t, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4661

Pre-translate a Matrix4x4 by a vector.

Parameters ​

m ​

Matrix4x4

The matrix that will be translated.

t ​

Vector3

The translate vector.

result? ​

Matrix4x4

The output matrix (can be the same as m), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix

Remarks ​

result = (translate matrix for t) * m


scaleRight() ​

static scaleRight(m, s, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4698

Post-scale a Matrix4x4 by a vector.

Parameters ​

m ​

Matrix4x4

The matrix that will be scaled.

s ​

Vector3

The scale vector.

result? ​

Matrix4x4

The output matrix (can be the same as m), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix

Remarks ​

result = m * (scale matrix for s)


scaleLeft() ​

static scaleLeft(m, s, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4745

Pre-scale a Matrix4x4 by a vector.

Parameters ​

m ​

Matrix4x4

The matrix that will be translated.

s ​

Vector3

The scale vector.

result? ​

Matrix4x4

The output matrix (can be the same as m), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix

Remarks ​

result = (scale matrix for s) * m


rotateRight() ​

static rotateRight(m, r, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4776

Post-rotate a Matrix4x4 by a rotation matrix or quaternion.

Parameters ​

m ​

Matrix4x4

The matrix that will be translated.

r ​

Quaternion | Matrix3x3 | Matrix4x4

The rotate matrix or quaternion.

result? ​

Matrix4x4

The output matrix (can be the same as m), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix

Remarks ​

result = m * r


rotateLeft() ​

static rotateLeft(m, r, result?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4834

Pre-rotate a Matrix4x4 by a rotation matrix or quaternion.

Parameters ​

m ​

Matrix4x4

The matrix that will be translated.

r ​

Quaternion | Matrix3x3 | Matrix4x4

The rotate matrix or quaternion.

result? ​

Matrix4x4

The output matrix (can be the same as m), if not specified, a new matrix will be created.

Returns ​

Matrix4x4

The output matrix

Remarks ​

result = r * m


subBy() ​

subBy(other): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4887

Subtract a matrix from this matrix component-wise.

Parameters ​

other ​

Matrix4x4

The matrix that will be subtract.

Returns ​

Matrix4x4

self


addBy() ​

addBy(other): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4896

Add a matrix to this matrix component-wise.

Parameters ​

other ​

Matrix4x4

The matrix that will be added.

Returns ​

Matrix4x4

self


mulBy() ​

mulBy(other): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4905

Multiplies this matrix by a matrix component-wise.

Parameters ​

other ​

Matrix4x4

The matrix that will be multiplied by.

Returns ​

Matrix4x4

self


divBy() ​

divBy(other): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4914

Divide this matrix by a matrix component-wise.

Parameters ​

other ​

Matrix4x4

The matrix that will be divide by.

Returns ​

Matrix4x4

self


scaleBy() ​

scaleBy(f): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4923

Scale this matrix by a scalar number component-wise.

Parameters ​

f ​

number

amount to scale this matrix by.

Returns ​

Matrix4x4

self


identity() ​

identity(): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4931

Make this matrix identity.

Returns ​

Matrix4x4

self


perspective() ​

perspective(fovY, aspect, znear, zfar): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4943

Calculates a right-handed perspective projection matrix inplace.

Parameters ​

fovY ​

number

The vertical field of view in radians.

aspect ​

number

The aspect ratio.

znear ​

number

The near clip plane.

zfar ​

number

The far clip plane.

Returns ​

Matrix4x4

self


frustum() ​

frustum(left, right, bottom, top, znear, zfar): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4957

Calculates a perspective projection matrix from a frustum inplace.

Parameters ​

left ​

number

Left bound of the frustum.

right ​

number

Right bound of the frustum.

bottom ​

number

Bottom bound of the frustum.

top ​

number

Top bound of the frustum.

znear ​

number

Near bound of the frustum.

zfar ​

number

Far bound of the frustum.

Returns ​

Matrix4x4

self


ortho() ​

ortho(left, right, bottom, top, near, far): Matrix4x4

Defined in: libs/base/src/math/vector.ts:4971

Calculates an orthogonal projection matrix inplace.

Parameters ​

left ​

number

Left bound of the frustum.

right ​

number

Right bound of the frustum.

bottom ​

number

Bottom bound of the frustum.

top ​

number

Top bound of the frustum.

near ​

number

Near bound of the frustum.

far ​

number

Far bound of the frustum.

Returns ​

Matrix4x4

self


isOrtho() ​

isOrtho(): boolean

Defined in: libs/base/src/math/vector.ts:4983

Check if this matrix is orthogonal projection matrix.

Returns ​

boolean

true if this is an orthogonal projection matrix, otherwise false

Remarks ​

This method assumes that this is an affine transform matrix or a projection matrix (perspective or orthogonal).


isPerspective() ​

isPerspective(): boolean

Defined in: libs/base/src/math/vector.ts:4995

Check if this matrix is perspective projection matrix.

Returns ​

boolean

true if this is a perspective projection matrix, otherwise false

Remarks ​

This method assumes that this is an affine transform matrix or a projection matrix (perspective or orthogonal).


getNearPlaneWidth() ​

getNearPlaneWidth(): number

Defined in: libs/base/src/math/vector.ts:5007

Get width of the near clip plane.

Returns ​

number

Width of the near clip plane

Remarks ​

This method assumes that this is a projection matrix (perspective or orthogonal).


getNearPlaneHeight() ​

getNearPlaneHeight(): number

Defined in: libs/base/src/math/vector.ts:5022

Get height of the near clip plane.

Returns ​

number

Height of the near clip plane

Remarks ​

This method assumes that this is a projection matrix (perspective or orthogonal).


getNearPlane() ​

getNearPlane(): number

Defined in: libs/base/src/math/vector.ts:5037

Get near clip plane.

Returns ​

number

The near clip plane

Remarks ​

This method assumes that this is a projection matrix (perspective or orthogonal).


getFarPlaneWidth() ​

getFarPlaneWidth(): number

Defined in: libs/base/src/math/vector.ts:5059

Get width of the far clip plane.

Returns ​

number

Width of the far clip plane

Remarks ​

This method assumes that this is a projection matrix (perspective or orthogonal).


getFarPlaneHeight() ​

getFarPlaneHeight(): number

Defined in: libs/base/src/math/vector.ts:5074

Get height of the far clip plane.

Returns ​

number

Height of the far clip plane

Remarks ​

This method assumes that this is a projection matrix (perspective or orthogonal).


getFarPlane() ​

getFarPlane(): number

Defined in: libs/base/src/math/vector.ts:5089

Get far clip plane.

Returns ​

number

The far clip plane

Remarks ​

This method assumes that this is a projection matrix (perspective or orthogonal).


getFov() ​

getFov(): number

Defined in: libs/base/src/math/vector.ts:5107

Get the vertical field of view in radians.

Returns ​

number

0 if this is an orthogonal projection matrix, otherwise the vertical field of view

Remarks ​

This method assumes that this is a projection matrix (perspective or orthogonal).


getTanHalfFov() ​

getTanHalfFov(): number

Defined in: libs/base/src/math/vector.ts:5120

Get tangent value of half of the vertical field of view.

Returns ​

number

0 if this is an orthogonal projection matrix, otherwise the tangent value of half of the vertical field of view

Remarks ​

This method assumes that this is a projection matrix (perspective or orthogonal). If the matrix is orthogonal, 0 is returned.


getAspect() ​

getAspect(): number

Defined in: libs/base/src/math/vector.ts:5132

Get the aspect ratio.

Returns ​

number

The aspect ratio

Remarks ​

This method assumes that the matrix is a perspective projection matrix.


getLeftPlane() ​

getLeftPlane(): number

Defined in: libs/base/src/math/vector.ts:5144

Get the left clip plane.

Returns ​

number

The left clip plane

Remarks ​

This method assumes that the matrix is an orthogonal projection matrix.


getRightPlane() ​

getRightPlane(): number

Defined in: libs/base/src/math/vector.ts:5159

Get the right clip plane.

Returns ​

number

The right clip plane

Remarks ​

This method assumes that the matrix is an orthogonal projection matrix.


getTopPlane() ​

getTopPlane(): number

Defined in: libs/base/src/math/vector.ts:5174

Get the top clip plane.

Returns ​

number

The top clip plane

Remarks ​

This method assumes that the matrix is an orthogonal projection matrix.


getBottomPlane() ​

getBottomPlane(): number

Defined in: libs/base/src/math/vector.ts:5189

Get the bottom clip plane.

Returns ​

number

The bottom clip plane

Remarks ​

This method assumes that the matrix is an orthogonal projection matrix.


setNearFar() ​

setNearFar(znear, zfar): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5206

Set the near clip plane and far clip plane.

Parameters ​

znear ​

number

The near clip plane.

zfar ​

number

The far clip plane.

Returns ​

Matrix4x4

self

Remarks ​

This method assumes that the matrix is a projection matrix (perspective or orthogonal).


translation() ​

translation(t): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5223

Calculate a translation matrix inplace.

Parameters ​

t ​

Vector3

The translate vector.

Returns ​

Matrix4x4

self


translationXYZ() ​

translationXYZ(tx, ty, tz): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5234

Calculates a translation matrix inplace with individual translation factors.

Parameters ​

tx ​

number

The translation of x axis.

ty ​

number

The translation of y axis.

tz ​

number

The translation of z axis.

Returns ​

Matrix4x4

self


scaling() ​

scaling(s): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5243

Calculates a scale matrix inplace.

Parameters ​

s ​

Vector3

The scale vector.

Returns ​

Matrix4x4

self


scalingXYZ() ​

scalingXYZ(sx, sy, sz): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5254

Calculates a scale matrix inplace with individual scale factors.

Parameters ​

sx ​

number

The scale of x axis.

sy ​

number

The scale of y axis.

sz ​

number

The scale of z axis.

Returns ​

Matrix4x4

self


inplaceInvert() ​

inplaceInvert(): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5262

Invert this matrix inplace.

Returns ​

Matrix4x4

self


inplaceInvertAffine() ​

inplaceInvertAffine(): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5270

Invert this matrix inplace, assuming this matrix presents an affine transformation.

Returns ​

Matrix4x4

self


transpose() ​

transpose(): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5278

Calculates the transpose of this matrix inplace.

Returns ​

Matrix4x4

self


multiplyRight() ​

multiplyRight(other): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5291

Post-multiply by a matrix inplace.

Parameters ​

other ​

Matrix4x4

The matrix that will be multiplied by.

Returns ​

Matrix4x4

self

Remarks ​

this = this * other


multiplyRightAffine() ​

multiplyRightAffine(other): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5304

Post-multiply by a matrix inplace, assuming both matrices present affine transformations.

Parameters ​

other ​

Matrix4x4

The matrix that will be multiplied by.

Returns ​

Matrix4x4

self

Remarks ​

this = this * other


multiplyLeft() ​

multiplyLeft(other): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5317

Pre-multiply by a matrix inplace.

Parameters ​

other ​

Matrix4x4

The matrix that will be multiplied by.

Returns ​

Matrix4x4

self

Remarks ​

this = other * this


multiplyLeftAffine() ​

multiplyLeftAffine(other): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5330

Pre-multiply by a matrix inplace, assuming both matrices present affine transformations.

Parameters ​

other ​

Matrix4x4

The matrix that will be multiplied by.

Returns ​

Matrix4x4

self

Remarks ​

this = other * this


rotationX() ​

rotationX(angle): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5339

Calculates a rotation around x axis inplace.

Parameters ​

angle ​

number

The rotate angle in radians.

Returns ​

Matrix4x4

self


rotationY() ​

rotationY(angle): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5348

Calculates a rotation around y axis inplace.

Parameters ​

angle ​

number

The rotate angle in radians.

Returns ​

Matrix4x4

self


rotationZ() ​

rotationZ(angle): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5357

Calculates a rotation around z axis inplace.

Parameters ​

angle ​

number

The rotate angle in radians.

Returns ​

Matrix4x4

self


rotation() ​

rotation(axis, angle): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5367

Calculates a rotation around a given axis inplace.

Parameters ​

axis ​

Vector3

The rotation axis.

angle ​

number

The rotate angle in radians.

Returns ​

Matrix4x4

self


translateRight() ​

translateRight(t): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5380

Post-translate by a vector inplace.

Parameters ​

t ​

Vector3

The translate vector.

Returns ​

Matrix4x4

self

Remarks ​

this = this * (translate matrix for t)


translateLeft() ​

translateLeft(t): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5393

Pre-translate by a vector inplace.

Parameters ​

t ​

Vector3

The translate vector.

Returns ​

Matrix4x4

self

Remarks ​

this = (translate matrix for t) * this


scaleRight() ​

scaleRight(s): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5406

Post-scale by a vector inplace.

Parameters ​

s ​

Vector3

The scale vector.

Returns ​

Matrix4x4

self

Remarks ​

this = this * (scale matrix for s)


scaleLeft() ​

scaleLeft(s): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5419

Pre-scale by a vector inplace.

Parameters ​

s ​

Vector3

The scale vector.

Returns ​

Matrix4x4

self

Remarks ​

this = (scale matrix for s) * this


rotateRight() ​

rotateRight(r): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5432

Post-rotate by a rotation matrix or quaternion inplace.

Parameters ​

r ​

Quaternion | Matrix3x3 | Matrix4x4

The rotation matrix or quaternion.

Returns ​

Matrix4x4

self

Remarks ​

this = this * r


rotateLeft() ​

rotateLeft(r): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5445

Pre-rotate by a rotation matrix or quaternion inplace.

Parameters ​

r ​

Quaternion | Matrix3x3 | Matrix4x4

The rotation matrix or quaternion.

Returns ​

Matrix4x4

self

Remarks ​

this = r * this


lookAt() ​

lookAt(eye, target, up): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5456

Calculates a look-at matrix inplace.

Parameters ​

eye ​

Vector3

Position of the eye.

target ​

Vector3

The point that the eye is looking at.

up ​

Vector3

The up vector.

Returns ​

Matrix4x4

self


transformPoint() ​

transformPoint(point, result?): Vector4

Defined in: libs/base/src/math/vector.ts:5466

Transform a point by this matrix.

Parameters ​

point ​

Vector3

The point to be transformed.

result? ​

Vector4

The output vector, if not specified, a new vector will be created.

Returns ​

Vector4

The output vector


transformPointP() ​

transformPointP(point, result?): Vector3

Defined in: libs/base/src/math/vector.ts:5481

Transform a point by this matrix and then do a perspective divide.

Parameters ​

point ​

Vector3

The point to be transformed.

result? ​

Vector3

The output vector, if not specified, a new vector will be created.

Returns ​

Vector3

The output vector


transformPointAffine() ​

transformPointAffine(point, result?): Vector3

Defined in: libs/base/src/math/vector.ts:5495

Transform a point by this matrix, assuming this matrix presents an affine transformation.

Parameters ​

point ​

Vector3

The point to be transformed.

result? ​

Vector3

The output vector (can be the same as point), if not specified, a new vector will be created.

Returns ​

Vector3

The output vector


transformVector() ​

transformVector(vec, result?): Vector4

Defined in: libs/base/src/math/vector.ts:5509

Transform a vector by this matrix.

Parameters ​

vec ​

Vector3

The vector to be transformed.

result? ​

Vector4

The output vector, if not specified, a new vector will be created.

Returns ​

Vector4

The output vector


transformVectorAffine() ​

transformVectorAffine(vec, result?): Vector3

Defined in: libs/base/src/math/vector.ts:5524

Transform a vector by this matrix assuming this matrix presents an affine transformation.

Parameters ​

vec ​

Vector3

The vector to be transformed.

result? ​

Vector3

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns ​

Vector3

The output vector


transformP() ​

transformP(vec, result?): Vector4

Defined in: libs/base/src/math/vector.ts:5538

Transform a vector by this matrix and then do a perspective divide.

Parameters ​

vec ​

Vector4

The vector to be transformed.

result? ​

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns ​

Vector4

The output vector


transform() ​

transform(vec, result?): Vector4

Defined in: libs/base/src/math/vector.ts:5552

Transform a vector by this matrix.

Parameters ​

vec ​

Vector4

The vector to be transformed.

result? ​

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns ​

Vector4

The output vector


transformAffine() ​

transformAffine(vec, result?): Vector4

Defined in: libs/base/src/math/vector.ts:5567

Transform a vector by this matrix, assuming this matrix presents an affine transformation.

Parameters ​

vec ​

Vector4

The vector to be transformed.

result? ​

Vector4

The output vector (can be the same as vec), if not specified, a new vector will be created.

Returns ​

Vector4

The output vector


det() ​

det(): number

Defined in: libs/base/src/math/vector.ts:5580

Calculates the determinant of this matrix.

Returns ​

number

The determinant


compose() ​

compose(scale, rotation, translation): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5616

Compose matrix from rotation, translation and scale components.

Parameters ​

scale ​

Vector3

The input scale vector.

rotation ​

Quaternion | Matrix3x3 | Matrix4x4

The input rotation matrix or quaternion.

translation ​

Vector3

The input translation vector.

Returns ​

Matrix4x4

self


decompose() ​

decompose(scale?, rotation?, translation?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5627

Decompose this matrix into its rotation, translation and scale components.

Parameters ​

scale? ​

Vector3

The output scale vector.

rotation? ​

Quaternion | Matrix3x3 | Matrix4x4

The output rotation matrix or quaternion.

translation? ​

Vector3

The output translation vector.

Returns ​

Matrix4x4

self


decomposeLookAt() ​

decomposeLookAt(eye?, target?, up?): Matrix4x4

Defined in: libs/base/src/math/vector.ts:5783

Decompose this matrix into a look-at form.

Parameters ​

eye? ​

Vector3

The output eye vector.

target? ​

Vector3

The output target vector.

up? ​

Vector3

The output up vector.

Returns ​

Matrix4x4

self

Released under the MIT License.