Communicator.Matrix

Matrix

## Constructors

### constructor

• Creates a new matrix set to the identity matrix.

m: SC.Matrix16

## Methods

### assign

• Sets the value of this matrix to another.

#### Parameters

• ##### matrix: Matrix

the matrix whose values will be set.

#### Returns Matrix

This matrix object.

### copy

• Creates a copy of this matrix.

#### Returns Matrix

Copy of this matrix.

### equals

• equals(other: Matrix): boolean
• Strictly compares this matrix with another.

#### Parameters

• ##### other: Matrix

Matrix to compare with.

#### Returns boolean

True if the values of this matrix equal those of the other.

### equalsWithTolerance

• equalsWithTolerance(other: Matrix, tolerance: number): boolean
• Compares this matrix with another using a tolerance.

#### Parameters

• ##### other: Matrix

Matrix to compare with.

• ##### tolerance: number

Tolerance to be used in the comparison.

#### Returns boolean

True if the values of this matrix equal those of the other.

### forJson    [deprecated]

• forJson(): Object
• deprecated

### inverseAndDeterminant

• inverseAndDeterminant(): [Matrix | null, number]
• Computes the determinant and inverse of a matrix, if possible.

#### Returns [Matrix | null, number]

An array containing the inverse (or null if not invertible) followed by the determinant

### isIdentity

• isIdentity(): boolean
• #### Returns boolean

• Sets the matrix to the identity matrix.

#### Returns Matrix

This matrix object.

### normalMatrix

• normalMatrix(): Matrix | null
• #### Returns Matrix | null

the version of this matrix suitable for applying to normals, i.e. the inverse transpose of the upper-left 3x3 submatrix.

### scale

• Scales all elements of the matrix.

#### Parameters

• ##### k: number

Constant value to scale elements by.

#### Returns Matrix

This matrix object.

### setScaleComponent

• setScaleComponent(x: number, y: number, z: number): Matrix
• Sets the scale components of this matrix.

#### Parameters

• ##### x: number

X scale value.

• ##### y: number

Y scale value.

• ##### z: number

Z scale value.

#### Returns Matrix

This matrix object.

### setTranslationComponent

• setTranslationComponent(x: number, y: number, z: number): Matrix
• Sets the translation components of this matrix.

#### Parameters

• ##### x: number

X translation value.

• ##### y: number

Y translation value.

• ##### z: number

Z translation value.

#### Returns Matrix

This matrix object.

### toJson

• toJson(): number[]
• Creates an object ready for JSON serialization.

#### Returns number[]

The prepared object.

### transform

• Transforms a point according to this matrix. The source and destination points are allowed to be the same object.

#### Parameters

• ##### point: Point3

The point to be transformed.

• ##### result: Point3

Point which will hold the result of the transformation.

#### Returns void

• Transforms a point according to this matrix.

#### Parameters

• ##### point: Point3

The point to be transformed.

#### Returns Point3

A new point which will hold the result of the transformation.

### transform4

• Transforms a point according to this matrix. The source and destination points are allowed to be the same object.

#### Parameters

• ##### point: Point4

The point to be transformed.

• ##### result: Point4

Point which will hold the result of the transformation.

#### Returns void

• Transforms a point according to this matrix.

#### Parameters

• ##### point: Point4

The point to be transformed.

#### Returns Point4

A new point which will hold the result of the transformation.

### transformArray

• transformArray(inPoints: Point3[], outPoints: Point3[]): void
• Transforms an array of points according to this matrix.

#### Parameters

• ##### inPoints: Point3[]

an array of points to be transformed.

• ##### outPoints: Point3[]

an array that will be populated with transformed points. Note that the results will be pushed onto the end of the array.

### transformBox

• transformBox(inBox: Box): Box

### transpose

• Sets this matrix equal to its transpose.

#### Returns Matrix

This matrix object.

### upperLeft3x3Determinant

• upperLeft3x3Determinant(): number
• Computes the determinant of the upper-left 3x3 subsection of this matrix.

• deprecated

### Static createFromArray

• createFromArray(arr: number[]): Matrix
• Creates a matrix from an array of numbers.

#### Parameters

• ##### arr: number[]

16 element array of numbers.

#### Returns Matrix

New matrix with elements set to the values of the array parameter

### Static createFromBasis

• Creates a matrix from three Point3s, which will be used as the columns of the matrix.

#### Parameters

• ##### xAxis: Point3

The first column.

• ##### yAxis: Point3

The second column.

• ##### zAxis: Point3

The third column.

### Static createFromOffAxisRotation

• Creates a rotation matrix from an arbitrary axis.

#### Parameters

• ##### degrees: Degrees

Amount of degrees to rotate about the provided axis.

#### Returns Matrix

Rotation matrix which represents the rotation about the supplied axis.

### Static fromJson

• Creates a new Matrix from an object given by toJson.

#### Returns Matrix

The prepared object.

### Static inverse

• Computes the inverse of a matrix if possible.

#### Parameters

• ##### matrix: Matrix

Matrix whose inverse will be computed.

#### Returns Matrix | null

Matrix set to the inverse of the supplied matrix.

### Static multiply

• Multiplies two matrices.

(p' = ABp <=> p' = multiply(B, A).transform(p))

#### Parameters

• ##### m1: Matrix

The first matrix.

• ##### m2: Matrix

The second matrix.

#### Returns Matrix

Matrix which is the result of the multiplication.

### Static xAxisRotation

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

#### Parameters

• ##### degrees: Degrees

The degrees of the rotation.

#### Returns Matrix

The rotation matrix.

### Static yAxisRotation

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

#### Parameters

• ##### degrees: Degrees

The degrees of the rotation.

#### Returns Matrix

The rotation matrix.

### Static zAxisRotation

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

#### Parameters

• ##### degrees: Degrees

The degrees of the rotation.

#### Returns Matrix

The rotation matrix.