Skip to content

Documentation / base / Matrix4x4

Class: Matrix4x4

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

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:3415

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:3437

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:3442

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:3448

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:3452

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:3528

Get the element at row 0, column 0

Returns

number

Set Signature

set m00(v): void

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

Parameters
v

number

Returns

void


m10

Get Signature

get m10(): number

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

Get the element at row 0, column 1

Returns

number

Set Signature

set m10(v): void

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

Parameters
v

number

Returns

void


m20

Get Signature

get m20(): number

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

Get the element at row 0, column 2

Returns

number

Set Signature

set m20(v): void

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

Parameters
v

number

Returns

void


m30

Get Signature

get m30(): number

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

Get the element at row 0, column 3

Returns

number

Set Signature

set m30(v): void

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

Parameters
v

number

Returns

void


m01

Get Signature

get m01(): number

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

Get the element at row 1, column 0

Returns

number

Set Signature

set m01(v): void

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

Parameters
v

number

Returns

void


m11

Get Signature

get m11(): number

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

Get the element at row 1, column 1

Returns

number

Set Signature

set m11(v): void

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

Parameters
v

number

Returns

void


m21

Get Signature

get m21(): number

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

Get the element at row 1, column 2

Returns

number

Set Signature

set m21(v): void

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

Parameters
v

number

Returns

void


m31

Get Signature

get m31(): number

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

Get the element at row 1, column 3

Returns

number

Set Signature

set m31(v): void

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

Parameters
v

number

Returns

void


m02

Get Signature

get m02(): number

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

Get the element at row 2, column 0

Returns

number

Set Signature

set m02(v): void

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

Parameters
v

number

Returns

void


m12

Get Signature

get m12(): number

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

Get the element at row 2, column 1

Returns

number

Set Signature

set m12(v): void

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

Parameters
v

number

Returns

void


m22

Get Signature

get m22(): number

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

Get the element at row 2, column 2

Returns

number

Set Signature

set m22(v): void

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

Parameters
v

number

Returns

void


m32

Get Signature

get m32(): number

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

Get the element at row 2, column 3

Returns

number

Set Signature

set m32(v): void

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

Parameters
v

number

Returns

void


m03

Get Signature

get m03(): number

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

Get the element at row 3, column 0

Returns

number

Set Signature

set m03(v): void

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

Parameters
v

number

Returns

void


m13

Get Signature

get m13(): number

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

Get the element at row 3, column 1

Returns

number

Set Signature

set m13(v): void

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

Parameters
v

number

Returns

void


m23

Get Signature

get m23(): number

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

Get the element at row 3, column 2

Returns

number

Set Signature

set m23(v): void

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

Parameters
v

number

Returns

void


m33

Get Signature

get m33(): number

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

Get the element at row 3, column 3

Returns

number

Set Signature

set m33(v): void

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

Parameters
v

number

Returns

void

Methods

equalsTo()

equalsTo(other, epsl?): boolean

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

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:51

Convert this to string object.

Returns

string

Inherited from

VectorBase.toString


isNaN()

isNaN(): boolean

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

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:74

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:3524

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:3645

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:3659

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:3675

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:3688

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:3697

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:3713

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:3727

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:3741

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:3755

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:3769

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:3783

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:3795

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:3811

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:3848

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:3877

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:3882

Parameters

projectionMatrix

Matrix4x4

clipPlane

Plane

Returns

Matrix4x4


obliquePerspective()

static obliquePerspective(perspectiveMatrix, nearPlane): Matrix4x4

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

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:3951

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:3989

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:4024

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:4107

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:4165

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:4194

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:4221

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:4250

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:4277

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:4306

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:4335

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:4365

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:4406

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:4423

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:4453

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:4478

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:4539

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:4596

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:4636

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:4673

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:4720

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:4751

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:4809

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:4862

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:4871

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:4880

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:4889

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:4898

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:4906

Make this matrix identity.

Returns

Matrix4x4

self


perspective()

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

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

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:4932

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:4946

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:4958

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:4970

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:4982

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:4997

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:5012

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:5027

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:5042

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:5057

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:5072

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:5085

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:5097

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:5109

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:5124

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:5139

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:5154

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:5171

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:5185

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:5196

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:5205

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:5216

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:5224

Invert this matrix inplace.

Returns

Matrix4x4

self


inplaceInvertAffine()

inplaceInvertAffine(): Matrix4x4

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

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:5240

Calculates the transpose of this matrix inplace.

Returns

Matrix4x4

self


multiplyRight()

multiplyRight(other): Matrix4x4

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

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:5266

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:5279

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:5292

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:5301

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:5310

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:5319

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:5329

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:5342

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:5355

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:5368

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:5381

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:5394

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:5407

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:5418

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:5428

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:5443

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:5457

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:5471

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:5486

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:5500

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:5514

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:5529

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:5542

Calculates the determinant of this matrix.

Returns

number

The determinant


compose()

compose(scale, rotation, translation): Matrix4x4

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

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:5589

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:5745

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.