Options
All
• Public
• Public/Protected
• All

# Class Matrix4x4

Represents a 4x4 matrix.

• Matrix
• Matrix4x4

• TransformId

## Constructors

### constructor

• new Matrix4x4(array?: ArrayLike<number>): Matrix4x4
• Creates a new transform matrix using the specified matrix array.

#### Parameters

• ##### Optional array: ArrayLike<number>

The matrix array, expected length is 16. If empty, an identity matrix is used by default.

## Properties

a: number
default

1

### array

array: Float32Array

The array containing the matrix data.

b: number
default

0

c: number
default

0

d: number
default

1

tx: number
default

0

ty: number
default

0

## Accessors

### rotation

• Returns the normalized rotation quaternion of the matrix.

### transformId

• get transformId(): number

### Static IDENTITY

• get IDENTITY(): Matrix
• A default (identity) matrix

### Static TEMP_MATRIX

• get TEMP_MATRIX(): Matrix
• A temp matrix

## Methods

### append

• Appends the given Matrix to this Matrix.

#### Parameters

• ##### matrix: Matrix

The matrix to append.

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### apply

• apply<P>(pos: IPointData, newPos?: P): P
• Get a new position with the current transformation applied. Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)

The origin

#### Returns P

The new point, transformed through this matrix

### applyInverse

• applyInverse<P>(pos: IPointData, newPos?: P): P
• Get a new position with the inverse of the current transformation applied. Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)

The origin

#### Returns P

The new point, inverse-transformed through this matrix

### clone

• clone(): Matrix
• Creates a new Matrix object with the same values as this one.

#### Returns Matrix

A copy of this matrix. Good for chaining method calls.

### copyTo

• copyTo(matrix: Matrix): Matrix
• Changes the values of the given matrix to be the same as the ones in this matrix

#### Parameters

• ##### matrix: Matrix

The matrix to copy to.

#### Returns Matrix

The matrix given in parameter with its values updated.

### decompose

• decompose(transform: Transform): Transform
• Decomposes the matrix (x, y, scaleX, scaleY, and rotation) and sets the properties on to a transform.

#### Parameters

• ##### transform: Transform

The transform to apply the properties to.

#### Returns Transform

The transform with the newly applied properties

### fromArray

• fromArray(array: number[]): void
• Creates a Matrix object based on the given array. The Element to Matrix mapping order is as follows:

a = array b = array c = array d = array tx = array ty = array

#### Parameters

• ##### array: number[]

The array that the matrix will be populated from.

### identity

• Resets this Matrix to an identity (default) matrix.

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### invert

• Inverts this matrix

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### multiply

• Multiplies this matrix with another matrix.

#### Parameters

• ##### matrix: Matrix4x4

The matrix to multiply with.

### prepend

• Prepends the given Matrix to this Matrix.

#### Parameters

• ##### matrix: Matrix

The matrix to prepend

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### rotate

• Applies a rotation transformation to the matrix.

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### scale

• Applies a scale transformation to the matrix.

#### Parameters

• ##### x: number

The amount to scale horizontally

• ##### y: number

The amount to scale vertically

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### set

• set(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix4x4
• Sets the matrix properties.

#### Parameters

• ##### a: number

Matrix component

• ##### b: number

Matrix component

• ##### c: number

Matrix component

• ##### d: number

Matrix component

• ##### tx: number

Matrix component

• ##### ty: number

Matrix component

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### setFrom

• Sets the matrix to the contents of the specified array.

The array.

### setFromRotationPositionScale

• Sets the rotation, position and scale components.

#### Parameters

• ##### rotation: Quaternion

The rotation to set.

• ##### position: Point3D

The position to set.

• ##### scaling: Point3D

The scale to set.

### setTransform

• setTransform(x: number, y: number, pivotX: number, pivotY: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number): Matrix4x4
• Sets the matrix based on all the available properties

#### Parameters

• ##### x: number

Position on the x axis

• ##### y: number

Position on the y axis

• ##### pivotX: number

Pivot on the x axis

• ##### pivotY: number

Pivot on the y axis

• ##### scaleX: number

Scale on the x axis

• ##### scaleY: number

Scale on the y axis

• ##### skewX: number

Skew on the x axis

• ##### skewY: number

Skew on the y axis

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### toArray

• toArray(transpose: boolean, out?: Float32Array): Float32Array

### toString

• toString(): string

### translate

• Translates the matrix on the x and y.

#### Parameters

• ##### x: number

How much to translate x by

• ##### y: number

How much to translate y by

#### Returns Matrix4x4

This matrix. Good for chaining method calls.

### Static fromQuaternion

• Calculates a matrix from the given quaternion.

#### Parameters

• ##### q: Quaternion

The quaternion to create matrix from.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static fromRotation

• Creates a matrix from a given angle around a given axis.

#### Parameters

The angle in radians to rotate the matrix by.

• ##### axis: Point3D

The axis to rotate around.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static fromRotationTranslationScale

• Creates a matrix from a quaternion rotation, point translation and point scale.

#### Parameters

• ##### q: Quaternion

The rotation quaternion.

• ##### v: Point3D

The translation point.

• ##### s: Point3D

The scale point.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static fromScaling

• Creates a matrix from a scaling point.

#### Parameters

• ##### v: Point3D

The scaling point.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static fromTranslation

• Creates a matrix from a scaling point.

#### Parameters

• ##### v: Point3D

The translation point.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static identity

• Set a matrix to the identity matrix.

#### Parameters

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static invert

• Inverts a matrix.

#### Parameters

• ##### a: Matrix4x4

The source matrix to invert.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static lookAt

• Generates a look-at matrix with the given eye position, focal point, and up axis. If you want a matrix that actually makes an object look at another object, you should use targetTo instead.

#### Parameters

• ##### eye: Point3D

The position of the viewer.

• ##### center: Point3D

The point the viewer is looking at.

• ##### up: Point3D

The vector pointing up.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static ortho

• ortho(left: number, right: number, bottom: number, top: number, near: number, far: number, out?: Matrix4x4): Matrix4x4
• #### Parameters

• ##### left: number

The left bound of the frustum.

• ##### right: number

The right bound of the frustum.

• ##### bottom: number

The bottom bound of the frustum.

• ##### top: number

The top bound of the frustum.

• ##### near: number

The near bound of the frustum.

• ##### far: number

The far bound of the frustum.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static perspective

• perspective(fovy: number, aspect: number, near: number, far: number, out?: Matrix4x4): Matrix4x4
• #### Parameters

• ##### fovy: number

The vertical field of view in radians.

• ##### aspect: number

The aspect ratio, typically viewport width/height.

• ##### near: number

The near bound of the frustum.

• ##### far: number

The far bound of the frustum.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static rotate

• Rotates a matrix by the given angle around the given axis.

#### Parameters

• ##### a: Matrix4x4

The matrix to rotate.

The angle in radians to rotate the matrix by.

• ##### axis: Point3D

The axis to rotate around.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static rotateX

• Rotates a matrix by the given angle around the x-axis.

#### Parameters

• ##### a: Matrix4x4

The matrix to rotate.

The angle in radians to rotate the matrix by.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static rotateY

• Rotates a matrix by the given angle around the y-axis.

#### Parameters

• ##### a: Matrix4x4

The matrix to rotate.

The angle in radians to rotate the matrix by.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static rotateZ

• Rotates a matrix by the given angle around the z-axis.

#### Parameters

• ##### a: Matrix4x4

The matrix to rotate.

The angle in radians to rotate the matrix by.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static scale

• Scales the matrix by the dimensions in the given point.

#### Parameters

• ##### a: Matrix4x4

The matrix to scale.

• ##### v: Point3D

The point vector to scale the matrix by.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static targetTo

• Generates a matrix that makes something look at something else.

#### Parameters

• ##### eye: Point3D

The position of the viewer.

• ##### target: Point3D

The point the viewer is looking at.

• ##### up: Point3D

The vector pointing up.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static translate

• Translate a matrix by the given vector.

#### Parameters

• ##### mat: Matrix4x4

The matrix to translate.

• ##### v: Point3D

The vector to translate by.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

### Static transpose

• Transpose the values of a matrix

#### Parameters

• ##### a: Matrix4x4

The source matrix to transpose.

• ##### out: Matrix4x4 = ...

The receiving matrix. If not supplied, a new matrix will be created.

#### Returns Matrix4x4

Generated using TypeDoc