Skip to main content

Matrix2

A matrix with 2 rows and 2 columns

For this page assume:

local myMat = matrices.mat2()

add(Matrix2)​

Adds the other matrix to this one

Returns self for chaining


scale(Vector2)​

Adds the other matrix to this one

Returns self for chaining

Example:

myMat:scale(2, 2)

apply(number)​

Treats the given values as a vector, augments this vector with a 1, multiplies it against the matrix, and returns a deaugmented vector of the first values

Example:

myMat:apply()

set(Matrix2)​

Sets this matrix to have the same values as the matrix passed in

Returns self for chaining

Example:

myMat:set()

copy()​

Creates and returns a new copy of this matrix

Example:

myMat:copy()

reset()​

Resets this matrix back to the identity matrix

Returns self for chaining

Example:

myMat:reset()

multiply(Matrix2)​

Multiplies this matrix by the other matrix, with the other matrix on the left

Returns self for chaining


rotate(number)​

Rotates this matrix by the specified amount, changing the values inside

Angles are given in degrees

Returns self for chaining

Example:

myMat:rotate(90)

sub(Matrix2)​

Subtracts the other matrix from this one

Returns self for chaining


augmented()​

Augments this matrix, adding an additional row and column

Puts a 1 along the diagonal in the new spot, and the rest are zero

Example:

myMat:augmented()

inverted()​

Returns a copy of this matrix, but inverted

Example:

myMat:inverted()

transposed()​

Returns a copy of this matrix, but transposed

Transposing means to swap the rows and the columns

Example:

myMat:transposed()

rightMultiplty(Matrix2)​

Multiplies this matrix by the other matrix, with the other matrix on the right

Returns self for chaining


applyDir(number)​

Treats the given values as a vector, augments this vector with a 0, multiplies it against the matrix, and returns a deaugmented vector of the first values

Example:

myMat:applyDir()

det()​

Calculates and returns the determinant of this matrix

Example:

myMat:det()

transpose()​

Transposes this matrix, changing the values inside

Transposing means to swap the rows and the columns

Returns self for chaining

Example:

myMat:transpose()

getColumn(int)​

Gets the given column of this matrix, as a vector

Indexing starts at 1, as usual

Example:

myMat:getColumn(1)

getRow(int)​

Gets the given row of this matrix, as a vector

Indexing starts at 1, as usual

Example:

myMat:getRow(1)

invert()​

Inverts this matrix, changing the values inside

Returns self for chaining

Example:

myMat:invert()