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 . 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:
.
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
-
Matrix2x3
–this
for chaining.
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
-
Matrix2x3
–this
for chaining.
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
-
Matrix2x3
– The resultant matrix.
public setTranslation
setTranslation(t) => void
Sets the translation of t
his 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 scalethis
matrix by.
scale(s) => void
Scales this
matrix uniformly by the given scalar, s
.
Parameters
-
s: number
– The vector to scalethis
matrix by.
public inverse
inverse() => Matrix2x3
Returns a new matrix that is the inverse of this
matrix which satisfies: .
Returns
-
Matrix2x3
– The inverted matrix.
public get
get(i) => number
Returns the matrix element at index i
. ().
Parameters
-
i: number
– The index that must be an integer .
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
-
Matrix2x3
– A copy of the matrix.
Static Methods
No static methods for Matrix2x3