Matrix

class Communicator.Matrix()

Object representing the 4x4 Matrix. More information can be found here.

Constructors

Properties


Constructors

constructor

Communicator.Matrix.constructor()

Creates a new matrix set to the identity matrix.

Return type

Communicator.Matrix

Properties

Communicator.Matrix.m

Methods

assign

Communicator.Matrix.assign(matrix)

Sets the value of this matrix to another.

Arguments
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
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

isIdentity

Communicator.Matrix.isIdentity()
Return type

boolean

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 see setScaleComponent

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
Return type

void

Communicator.Matrix.transform(point)

Transforms a point according to this matrix.

Arguments
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
Return type

void

Communicator.Matrix.transform4(point)

Transforms a point according to this matrix.

Arguments
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
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
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 by toJson

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
Return type

{  }

Returns

Matrix set to the inverse of the supplied matrix.

multiply

Communicator.Matrix.multiply(m1, m2)

Multiplies two matrices.

Arguments
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.

yAxisRotation

Communicator.Matrix.yAxisRotation(degrees)

Returns the matrix for a rotation around the Y-axis, using the right-hand rule.

Arguments
  • degrees (Communicator.Degrees()) – The degrees of the rotation.

Return type

Communicator.Matrix

Returns

The rotation matrix.

zAxisRotation

Communicator.Matrix.zAxisRotation(degrees)

Returns the matrix for a rotation around the Z-axis, using the right-hand rule.

Arguments
  • degrees (Communicator.Degrees()) – The degrees of the rotation.

Return type

Communicator.Matrix

Returns

The rotation matrix.