# B.Math.Matrix3()

Represents a column-major 3x3 matrix.

make / set: representation: array accessor:
m00, m01, m02 axisX.x, axisY.x, axisZ.x m[0], m[3], m[6]
m10, m11, m12 = axisX.y, axisY.y, axisZ.y = m[1], m[4], m[7]
m20, m21, m22 axisX.z, axisY.z, axisZ.z m[2], m[5], m[8]

To create the object use B.Math.makeMatrix3().

Note: the order of transformations coincides with the order in which the matrices are multiplied (from left to right).

## CONSTANTS:

ZERO = [0,0,0, 0,0,0, 0,0,0]

Zero matrix.

IDENTITY = [1,0,0, 0,1,0, 0,0,1]

Identity matrix.

## PROPERTIES:

{Array.<number>} m

Matrix element array.

## METHODS:

clone()

Clones this matrix to a new matrix.

### RETURNS:

this

copy(matrix)

Copies a given matrix into this matrix.

matrix

### RETURNS:

this

set(m00, m01, m02, m10, m11, m12, m20, m21, m22)

Sets all elements of this matrix.

{number} m00

{number} m01

{number} m02

{number} m10

{number} m11

{number} m12

{number} m20

{number} m21

{number} m22

### RETURNS:

this

get(row, column)

Gets an element by its row and column indices.

{number} row

index [0, 2]

{number} column

index [0, 2]

{number}

### THROWS:

{Error}

if the index is out of range

setAxisX(axis)

Sets the X-axis vector.

axis

### RETURNS:

this

getAxisX(result)

Returns the X-axis vector.

### PARAMETERS:

[result]

omit if you want to return newly created vector

### RETURNS:

setAxisY(axis)

Sets the Y-axis vector.

axis

### RETURNS:

this

getAxisY(result)

Returns the Y-axis vector.

### PARAMETERS:

[result]

omit if you want to return newly created vector

### RETURNS:

setAxisZ(axis)

Sets the Z-axis vector.

axis

### RETURNS:

this

getAxisZ(result)

Returns the Z-axis vector.

### PARAMETERS:

[result]

omit if you want to return newly created vector

### RETURNS:

extractScale(result)

Extracts scale factors.

### PARAMETERS:

[result]

omit if you want to return newly created vector

### RETURNS:

fromArray(array, offset)

Sets this matrix elements from a part of array.

### PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

### RETURNS:

{number}

new offset

toArray(array, offset)

Sets this matrix elements to a part of array.

### PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

### RETURNS:

{number}

new offset

fromAngles(angles)

Sets this matrix from Euler angles.

angles

### RETURNS:

this

fromQuaternion(q)

Sets this matrix from a quaternion.

### RETURNS:

this

identity()

Sets this matrix to the identity.

### RETURNS:

this

rotationX(angle)

Sets this matrix to X-axis rotation transform.

{number} angle

### RETURNS:

this

rotationY(angle)

Sets this matrix to Y-axis rotation transform.

{number} angle

### RETURNS:

this

rotationZ(angle)

Sets this matrix to Z-axis rotation transform.

{number} angle

### RETURNS:

this

rotationAxis(axis, angle)

Sets this matrix to arbitrary axis rotation transform.

axis

{number} angle

### RETURNS:

this

scale(x, y, z)

Sets this matrix to scale transform.

{number} x

{number} y

{number} z

### RETURNS:

this

Adds a matrix to this matrix.

matrix

### RETURNS:

this

mulScalar(scalar)

Multiplies this matrix by a given scalar.

{number} scalar

### RETURNS:

this

mulMatrices(a, b)

Multiplies two given matrices and sets the result to this.

### RETURNS:

this

mul(value)

Multiplies this matrix by a given matrix or a scalar.

### PARAMETERS:

{number | B.Math.Matrix3} value

### RETURNS:

this

determinant()

Calculates the determinant of this matrix.

### RETURNS:

{number}

transpose()

Transposes this matrix.

### RETURNS:

this

invert()

Inverts this matrix.

this

### THROWS:

{Error}

if determinant is zero.

equal(matrix)

Checks for strict equality of this matrix and another matrix.

matrix

{boolean}