Skip to main content

Matrix

Matrix2x3

A representation of a 2x3 Matrix. Commonly used to represent the transform of a 2D object. This matrix really represents a 3x3 matrix with the last row being [0,0,1][0, 0, 1]. The first two columns represent the scale and rotation of the object (indices [0, 3]), while the last column represents the translation of the object (indices [4, 5]).

The indices are laid out in column-major order:

[024135]\begin{bmatrix} 0 & 2 & 4 \\ 1 & 3 & 5 \end{bmatrix}

.


Constructor

public Matrix2x3

new Matrix2x3()

Initializes a 2x3 Identity Matrix with all zeros except indices 0, 3 as ones.

new Matrix2x3(other)

Creates a 2x3 Matrix with values copied from other.

Parameters

  •  other: Matrix2x3 – The other matrix in which to copy.

Properties

No publicly accessible properties on Matrix2x3

private mat: number[]

Description needed


Methods

public zero

zero() => Matrix2x3

Sets all of the values in this Matrix to 0.

Returns

public identity

identity() => Matrix2x3

Zeros all the values in this Matrix except at index 0 and 3 which are set to 1 to represent an Identity matrix.

Returns

public mul

mul(other) => Vector

Return the result of this Matrix multiplied by the other Vector, resulting in a Vector.

Parameters

  •  other: Vector – The vector to multiply with this.

Returns

  •   Vector – The resultant vector.

public mult

mult(other) => Matrix2x3

Returns the result of this Matrix multiplied with the other Matrix, resulting in another 2x3 Matrix.

Parameters

  •  other: Matrix2x3 – The other matrix to multiply with this.

Returns

public setTranslation

setTranslation(t) => void

Sets the translation of this Matrix (last column) to t.

Parameters

  •  t: Vector – The translation vector.

public translate

translate(t) => void

Translates this by t depending on the rotation of this matrix.

Parameters

  •  t: Vector – The translation vector.

public rotate

rotate(theta) => void

Rotates this matrix by theta (in radians).

Parameters

  •  theta: number – The angle to rotate by (in radians).

public scale

scale(s) => void

Scales this matrix non-uniformly by the given vector, s.

Parameters

  •  s: Vector – The vector to scale this matrix by.

scale(s) => void

Scales this matrix uniformly by the given scalar, s.

Parameters

  •  s: number – The vector to scale this matrix by.

public inverse

inverse() => Matrix2x3

Returns a new matrix that is the inverse of this matrix which satisfies: MM1=M1M=IMM^{-1} = M^{-1}M = I.

Returns

public get

get(i) => number

Returns the matrix element at index i. (i[0,5]i \in [0, 5]).

Parameters

  •  i: number – The index that must be an integer [0,5]\in [0, 5].

Returns

  •   number – The matrix corresponding element value.

public getTranslation

getTranslation() => Vector

Returns the translation of this matrix (last column).

Returns

  •   Vector – The translation vector.

public equals

equals(other) => false | true

Returns whether or not this matrix has the same components as other.

Parameters

  •  other: Matrix2x3 – The other matrix to compare with.

Returns

  •   false | true – True if the two matrices are equal, false otherwise.

public copy

copy() => Matrix2x3

Return a copy of this Matrix with the same components.

Returns


Static Methods

No static methods for Matrix2x3