Matrix
- class Communicator.Matrix()
Object representing the 4x4 Matrix. More information can be found here.
Constructors
Properties
Methods
Constructors
Methods
assign
- Communicator.Matrix.assign(matrix)
Sets the value of this matrix to another.
- Arguments
matrix (
Communicator.Matrix()
) – the matrix whose values will be set.
- Return type
Communicator.Matrix
- Returns
This matrix object.
copy
- Communicator.Matrix.copy()
Creates a copy of this matrix.
- Return type
Communicator.Matrix
- Returns
Copy of this matrix.
equals
- Communicator.Matrix.equals(other)
Strictly compares this matrix with another.
- Arguments
other (
Communicator.Matrix()
) – Matrix to compare with.
- Return type
boolean
- Returns
True if the values of this matrix equal those of the other.
equalsWithTolerance
- Communicator.Matrix.equalsWithTolerance(other, tolerance)
Compares this matrix with another using a tolerance.
- Arguments
other (
Communicator.Matrix()
) – Matrix to compare with.tolerance (
number()
) – Tolerance to be used in the comparison.
- Return type
boolean
- Returns
True if the values of this matrix equal those of the other.
forJson
- Communicator.Matrix.forJson()
Note
forJson is deprecated: Use
toJson
instead.- Return type
Object
inverseAndDeterminant
- Communicator.Matrix.inverseAndDeterminant()
Computes the determinant and inverse of a matrix, if possible.
- Return type
({ }, number)
- Returns
An array containing the inverse (or null if not invertible) followed by the determinant
loadIdentity
- Communicator.Matrix.loadIdentity()
Sets the matrix to the identity matrix.
- Return type
Communicator.Matrix
- Returns
This matrix object.
multiplyByScalar
- Communicator.Matrix.multiplyByScalar(scalar)
Multiply the matrix by given scalar.
- Arguments
scalar (
number()
) – Scalar to multiply the matrix with.
- Return type
Communicator.Matrix
- Returns
This matrix object.
normalMatrix
- Communicator.Matrix.normalMatrix()
- Return type
{ }
- Returns
the version of this matrix suitable for applying to normals, i.e. the inverse transpose of the upper-left 3x3 submatrix.
scale
- Communicator.Matrix.scale(k)
Scales all elements of the matrix.
Note
scale is deprecated: For multiplying all elements by a scalar see
scalarMultiply
For setting scale component seesetScaleComponent
- Arguments
k (
number()
) – Constant value to scale elements by.
- Return type
Communicator.Matrix
- Returns
This matrix object.
setScaleComponent
- Communicator.Matrix.setScaleComponent(x, y, z)
Sets the scale components of this matrix.
- Arguments
x (
number()
) – X scale value.y (
number()
) – Y scale value.z (
number()
) – Z scale value.
- Return type
Communicator.Matrix
- Returns
This matrix object.
setTranslationComponent
- Communicator.Matrix.setTranslationComponent(x, y, z)
Sets the translation components of this matrix.
- Arguments
x (
number()
) – X translation value.y (
number()
) – Y translation value.z (
number()
) – Z translation value.
- Return type
Communicator.Matrix
- Returns
This matrix object.
toJson
- Communicator.Matrix.toJson()
Creates an object ready for JSON serialization.
- Return type
[number]
- Returns
The prepared object.
transform
- Communicator.Matrix.transform(point, result)
Transforms a point according to this matrix. The source and destination points are allowed to be the same object.
- Arguments
point (
Communicator.Point3()
) – The point to be transformed.result (
Communicator.Point3()
) – Point which will hold the result of the transformation.
- Return type
void
- Communicator.Matrix.transform(point)
Transforms a point according to this matrix.
- Arguments
point (
Communicator.Point3()
) – The point to be transformed.
- Return type
Communicator.Point3
- Returns
A new point which will hold the result of the transformation.
transform4
- Communicator.Matrix.transform4(point, result)
Transforms a point according to this matrix. The source and destination points are allowed to be the same object.
- Arguments
point (
Communicator.Point4()
) – The point to be transformed.result (
Communicator.Point4()
) – Point which will hold the result of the transformation.
- Return type
void
- Communicator.Matrix.transform4(point)
Transforms a point according to this matrix.
- Arguments
point (
Communicator.Point4()
) – The point to be transformed.
- Return type
Communicator.Point4
- Returns
A new point which will hold the result of the transformation.
transformArray
- Communicator.Matrix.transformArray(inPoints, outPoints)
Transforms an array of points according to this matrix.
- Arguments
inPoints (
[Communicator.Point3]()
) – an array of points to be transformed.outPoints (
[Communicator.Point3]()
) – an array that will be populated with transformed points. Note that the results will be pushed onto the end of the array.
- Return type
void
transformBox
- Communicator.Matrix.transformBox(inBox)
- Arguments
inBox (
Communicator.Box()
) –
- Return type
Communicator.Box
transpose
- Communicator.Matrix.transpose()
Sets this matrix equal to its transpose.
- Return type
Communicator.Matrix
- Returns
This matrix object.
upperLeft3x3Determinant
- Communicator.Matrix.upperLeft3x3Determinant()
Computes the determinant of the upper-left 3x3 subsection of this matrix.
- Return type
number
construct
- Communicator.Matrix.construct(obj)
Note
construct is deprecated: Use
fromJson
instead.- Arguments
obj (
any()
) –
- Return type
Communicator.Matrix
createFromArray
- Communicator.Matrix.createFromArray(arr)
Creates a matrix from an array of numbers.
- Arguments
arr (
[number]()
) – 16 element array of numbers.
- Return type
Communicator.Matrix
- Returns
New matrix with elements set to the values of the array parameter
createFromBasis
- Communicator.Matrix.createFromBasis(xAxis, yAxis, zAxis)
Creates a matrix from three [[Point3]]s, which will be used as the columns of the matrix.
- Arguments
xAxis (
Communicator.Point3()
) – The first column.yAxis (
Communicator.Point3()
) – The second column.zAxis (
Communicator.Point3()
) – The third column.
- Return type
Communicator.Matrix
createFromOffAxisRotation
- Communicator.Matrix.createFromOffAxisRotation(axis, degrees)
Creates a rotation matrix from an arbitrary axis.
- Arguments
axis (
Communicator.Point3()
) – Axis to rotate about.degrees (
Communicator.Degrees()
) – Amount of degrees to rotate about the provided axis.
- Return type
Communicator.Matrix
- Returns
Rotation matrix which represents the rotation about the supplied axis.
fromJson
- Communicator.Matrix.fromJson(obj)
Creates a new
Matrix
from an object given bytoJson
- Arguments
obj (
any()
) –
- Return type
Communicator.Matrix
- Returns
The prepared object.
inverse
- Communicator.Matrix.inverse(matrix)
Computes the inverse of a matrix if possible.
- Arguments
matrix (
Communicator.Matrix()
) – Matrix whose inverse will be computed.
- Return type
{ }
- Returns
Matrix set to the inverse of the supplied matrix.
multiply
- Communicator.Matrix.multiply(m1, m2)
Multiplies two matrices.
- Arguments
m1 (
Communicator.Matrix()
) – The first matrix.m2 (
Communicator.Matrix()
) – The second matrix.
- Return type
Communicator.Matrix
- Returns
Matrix which is the result of the multiplication.
(p’ = ABp <=> p’ = multiply(B, A).transform(p))
xAxisRotation
- Communicator.Matrix.xAxisRotation(degrees)
Returns the matrix for a rotation around the X-axis, using the right-hand rule.
- Arguments
degrees (
Communicator.Degrees()
) – The degrees of the rotation.
- Return type
Communicator.Matrix
- Returns
The rotation matrix.