Matrix
-
class
Matrix() Object representing the 4x4 Matrix. More information can be found here.
Index
Constructors
Properties
Methods
assigncopyequalsequalsWithToleranceinverseAndDeterminantisIdentityloadIdentitymultiplyByScalarnormalMatrixsetScaleComponentsetTranslationComponenttoJsontransformtransform4transformArraytransformBoxtransposeupperLeft3x3DeterminantcreateFromArraycreateFromBasiscreateFromOffAxisRotationfromJsoninversemultiplyxAxisRotationyAxisRotationzAxisRotation
Constructors
Methods
-
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.
-
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.
-
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.
-
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
-
Matrix.isIdentity() - isIdentity(): boolean
Returns: boolean
-
Matrix.loadIdentity() - loadIdentity(): this
Sets the matrix to the identity matrix.
Returns: this
This matrix object.
-
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.
-
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.
-
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.
-
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.
-
Matrix.toJson() - toJson(): number[]
Creates an object ready for JSON serialization.
Returns: number[]
The prepared object.
-
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.
-
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.
-
Matrix.transformArray() -
Transforms an array of points according to this matrix.
Parameters
Returns: void
-
Matrix.transpose() - transpose(): this
Sets this matrix equal to its transpose.
Returns: this
This matrix object.
-
Matrix.upperLeft3x3Determinant() - upperLeft3x3Determinant(): number
Computes the determinant of the upper-left 3x3 subsection of this matrix.
Returns: number
-
static 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 Matrix.createFromBasis() static
Creates a matrix from three [[Point3]]s, which will be used as the columns of the matrix.
Parameters
Returns:
Matrix
-
static 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 Matrix.fromJson() static
fromJson(obj: unknown):MatrixCreates a new [[Matrix]] from an object given by [[toJson]].
Parameters
obj: unknownReturns:
MatrixThe prepared object.
-
static 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 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 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.