Matrix
-
class
common.Matrix() Object representing the 4x4 Matrix. More information can be found here.
Index
Constructors
Properties
Methods
createFromArraycreateFromBasiscreateFromOffAxisRotationfromJsoninversemultiplyxAxisRotationyAxisRotationzAxisRotationassigncopyequalsequalsWithToleranceinverseAndDeterminantisIdentityloadIdentitymultiplyByScalarnormalMatrixsetScaleComponentsetTranslationComponenttoJsontransformtransform4transformArraytransformBoxtransposeupperLeft3x3Determinant
Constructors
-
common.Matrix.constructor() - Matrix():
MatrixCreates a new matrix set to the identity matrix.
Returns:
Matrix
Properties
Methods
-
static common.Matrix.createFromArray() static
createFromArray(arr: number[]):MatrixCreates a matrix from an array of numbers.
Parameters
arr: number[]
16 element array of numbers.Returns:
MatrixNew matrix with elements set to the values of the array parameter. Array elements will be in column-major order.
-
static common.Matrix.createFromBasis() static
Creates a matrix from three [[Point3]]s, which will be used as the columns of the matrix.
Parameters
Returns:
Matrix
-
static common.Matrix.createFromOffAxisRotation() static
Creates a rotation matrix from an arbitrary axis.
Parameters
axis:
Point3Axis to rotate about.degrees: number
Amount of degrees to rotate about the provided axis.Returns:
MatrixRotation matrix which represents the rotation about the supplied axis.
-
static common.Matrix.fromJson() static
fromJson(obj: unknown):MatrixCreates a new [[Matrix]] from an object given by [[toJson]].
Parameters
obj: unknown
An object given by [[toJson]].Returns:
MatrixThe prepared object.
-
static common.Matrix.inverse() static
Computes the inverse of a matrix if possible.
Parameters
matrix:
MatrixMatrix whose inverse will be computed.Returns: (None |
Matrix)Matrix set to the inverse of the supplied matrix.
-
static common.Matrix.multiply() static
Multiplies two matrices.
(p’ = ABp <=> p’ = multiply(B, A).transform(p))
Parameters
Returns:
MatrixMatrix which is the result of the multiplication.
-
static common.Matrix.xAxisRotation() static
xAxisRotation(degrees: number):MatrixReturns the matrix for a clockwise rotation around the X-axis.
Parameters
degrees: number
The degrees of the rotation.Returns:
MatrixThe rotation matrix.
-
static common.Matrix.yAxisRotation() static
yAxisRotation(degrees: number):MatrixReturns the matrix for a clockwise rotation around the Y-axis.
Parameters
degrees: number
The degrees of the rotation.Returns:
MatrixThe rotation matrix.
-
static common.Matrix.zAxisRotation() static
zAxisRotation(degrees: number):MatrixReturns the matrix for a clockwise rotation around the Z-axis.
Parameters
degrees: number
The degrees of the rotation.Returns:
MatrixThe rotation matrix.
-
common.Matrix.assign() - assign(matrix:
Matrix): thisSets the value of this matrix to another.
Parameters
matrix:
Matrixthe matrix whose values will be set.Returns: this
This matrix object.
-
common.Matrix.copy() - copy():
MatrixCreates a copy of this matrix.
Returns:
MatrixCopy of this matrix.
-
common.Matrix.equals() - equals(other:
Matrix): booleanStrictly compares this matrix with another.
Parameters
other:
MatrixMatrix to compare with.Returns: boolean
True if the values of this matrix equal those of the other.
-
common.Matrix.equalsWithTolerance() - equalsWithTolerance(other:
Matrix, tolerance: number): booleanCompares this matrix with another using a tolerance.
Parameters
Returns: boolean
True if the values of this matrix equal those of the other.
-
common.Matrix.inverseAndDeterminant() - inverseAndDeterminant(): [(None |
Matrix), number]Computes the determinant and inverse of a matrix, if possible.
Returns: [(None |
Matrix), number]An array containing the inverse (or null if not invertible) followed by the determinant
-
common.Matrix.isIdentity() - isIdentity(): boolean
Returns: boolean
-
common.Matrix.loadIdentity() - loadIdentity(): this
Sets the matrix to the identity matrix.
Returns: this
This matrix object.
-
common.Matrix.multiplyByScalar() - multiplyByScalar(scalar: number): this
Multiply the matrix by given scalar.
Parameters
scalar: number
Scalar to multiply the matrix with.Returns: this
This matrix object.
-
common.Matrix.normalMatrix() - normalMatrix(): (None |
Matrix)Returns: (None |
Matrix)the version of this matrix suitable for applying to normals, i.e. the inverse transpose of the upper-left 3x3 submatrix.
-
common.Matrix.setScaleComponent() - setScaleComponent(x: number, y: number, z: number): this
Sets the scale components of this matrix.
Parameters
x: number
X scale value.y: number
Y scale value.z: number
Z scale value.Returns: this
This matrix object.
-
common.Matrix.setTranslationComponent() - setTranslationComponent(x: number, y: number, z: number): this
Sets the translation components of this matrix.
Parameters
x: number
X translation value.y: number
Y translation value.z: number
Z translation value.Returns: this
This matrix object.
-
common.Matrix.toJson() - toJson(): number[]
Creates an object ready for JSON serialization.
Returns: number[]
The prepared object.
-
common.Matrix.transform() -
Transforms a point according to this matrix. The source and destination points are allowed to be the same object.
Parameters
Returns:
Point3A new point if result is undefined, result otherwise.
-
common.Matrix.transform4() -
Transforms a point according to this matrix. The source and destination points are allowed to be the same object.
Parameters
Returns:
Point4A new point if result is undefined, result otherwise.
-
common.Matrix.transformArray() -
Transforms an array of points according to this matrix.
Parameters
Returns: void
-
common.Matrix.transpose() - transpose(): this
Sets this matrix equal to its transpose.
Returns: this
This matrix object.
-
common.Matrix.upperLeft3x3Determinant() - upperLeft3x3Determinant(): number
Computes the determinant of the upper-left 3x3 subsection of this matrix.
Returns: number