Matrix3
A matrix with 3 rows and 3 columns
This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.
For this entire page assume:
local myMat = matrices.mat3()
Math
add()
Adds the other matrix to this one
Returns self for chaining
add(other)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other | Matrix3 | - | - |
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:add(matrices.mat3():scale(2))
sub()
Subtracts the other matrix from this one
Returns self for chaining
sub(other)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other | Matrix3 | - | - |
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:sub(matrices.mat3():scale(2))
det()
Calculates and returns the determinant of this matrix
det()
Returns:
Type | Description |
---|---|
Number | - |
Example:
myMat:det()
invert()
Inverts this matrix, changing the values inside
Returns self for chaining
invert()
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:invert()
inverted()
Returns a copy of this matrix, but inverted
inverted()
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:inverted()
multiply()
Multiplies this matrix by the other matrix, with the other matrix on the left
Returns self for chaining
multiply(other)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other | Matrix3 | - | - |
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:multiply(matrices.mat3():scale(2))
rightMultiply()
Multiplies this matrix by the other matrix, with the other matrix on the right
Returns self for chaining
rightMultiply(other)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other | Matrix3 | - | - |
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:rightMultiply(matrices.mat3():scale(2))
Accessors
getColumn()
Gets the given column of this matrix, as a vector
Indexing starts at 1, as usual
getColumn(col)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
col | Integer | - | - |
Returns:
Type | Description |
---|---|
Vector3 | - |
Example:
myMat:getColumn(1)
getRow()
Gets the given row of this matrix, as a vector
Indexing starts at 1, as usual
getRow(row)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row | Integer | - | - |
Returns:
Type | Description |
---|---|
Vector3 | - |
Example:
myMat:getRow(1)
Transformation
apply()
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
- Overload 1
- Overload 2
Example:
myMat:apply()
applyDir()
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
- Overload 1
- Overload 2
Example:
myMat:applyDir()
rotate()
Rotates this matrix by the specified amount, changing the values inside
Angles are given in degrees
Returns self for chaining
- Overload 1
- Overload 2
Example:
myMat:rotate(90, 90, 90)
rotateX()
Rotates this matrix around the X axis by the specified number of degrees
Returns self for chaining
rotateX(degrees)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
degrees | Number | - | - |
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:rotateX(90)
rotateY()
Rotates this matrix around the Y axis by the specified number of degrees
Returns self for chaining
rotateY(degrees)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
degrees | Number | - | - |
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:rotateY(90)
rotateZ()
Rotates this matrix around the Z axis by the specified number of degrees
Returns self for chaining
rotateZ(degrees)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
degrees | Number | - | - |
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:rotateZ(90)
scale()
Scales this matrix by the specified amount, changing the values inside
Returns self for chaining
- Overload 1
- Overload 2
Example:
myMat:scale(2, 2, 2)
translate()
Translates this matrix by the specified amount, changing the values inside
Returns self for chaining
- Overload 1
- Overload 2
Example:
myMat:translate(2, 2, 2)
transpose()
Transposes this matrix, changing the values inside
Transposing means to swap the rows and the columns
Returns self for chaining
transpose()
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:transpose()
transposed()
Returns a copy of this matrix, but transposed
Transposing means to swap the rows and the columns
transposed()
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:transposed()
Utility
set()
Sets this matrix to have the same values as the matrix passed in
Returns self for chaining
set(other)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other | Matrix3 | - | - |
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:set()
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
augmented()
Returns:
Type | Description |
---|---|
Matrix4 | - |
Example:
myMat:augmented()
copy()
Creates and returns a new copy of this matrix
copy()
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:copy()
deaugmented()
Deaugments this matrix, removing a row and column
deaugmented()
Returns:
Type | Description |
---|---|
Matrix2 | - |
Example:
myMat:deaugmented()
reset()
Resets this matrix back to the identity matrix
Returns self for chaining
reset()
Returns:
Type | Description |
---|---|
Matrix3 | Returns self for chaining |
Example:
myMat:reset()