B.Math.Matrix4()

Represents a column-major 4x4 matrix.

make / set: representation: array accessor:
m00, m01, m02, m03 axisX.x, axisY.x, axisZ.x, position.x m[0], m[4], m[08], m[12]
m10, m11, m12, m13 = axisX.y, axisY.y, axisZ.y, position.y = m[1], m[5], m[09], m[13]
m20, m21, m22, m23 axisX.z, axisY.z, axisZ.z, position.z m[2], m[6], m[10], m[14]
m30, m31, m32, m33 0, 0, 0, 1 m[3], m[7], m[11], m[15]

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

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

CONSTANTS:

{B.Math.Matrix4} ZERO = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]

Zero matrix.

{B.Math.Matrix4} IDENTITY = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]

Identity matrix.

PROPERTIES:

{Array.<number>} m

Matrix element array.

METHODS:

clone()

Clones this matrix to a new matrix.

RETURNS:

copy(matrix)

Copies a given matrix into this matrix.

PARAMETERS:

{B.Math.Matrix4} matrix

RETURNS:

set(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)

Sets all elements of this matrix.

PARAMETERS:

{number} m00

{number} m01

{number} m02

{number} m03

{number} m10

{number} m11

{number} m12

{number} m13

{number} m20

{number} m21

{number} m22

{number} m23

{number} m30

{number} m31

{number} m32

{number} m33

RETURNS:

get(row, column)

Gets an element by its row and column indices.

PARAMETERS:

{number} row

index [0, 3]

{number} column

index [0, 3]

RETURNS:

{number}

THROWS:

{Error}

if the index is out of range.

setMatrix3(matrix)

Sets 3x3 top left part of this matrix.

PARAMETERS:

{B.Math.Matrix3} matrix

RETURNS:

getMatrix3(result)

Returns 3x3 top left part of this matrix.

PARAMETERS:

{B.Math.Matrix3} [result]

omit if you want to return newly created matrix

RETURNS:

setAxisX(axis)

Sets the X-axis vector.

PARAMETERS:

RETURNS:

getAxisX(result)

Returns the X-axis vector.

PARAMETERS:

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

setAxisY(axis)

Sets the Y-axis vector.

PARAMETERS:

RETURNS:

getAxisY(result)

Returns the Y-axis vector.

PARAMETERS:

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

setAxisZ(axis)

Sets the Z-axis vector.

PARAMETERS:

RETURNS:

getAxisZ(result)

Returns the Z-axis vector.

PARAMETERS:

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

setPosition(position)

Sets the position vector.

PARAMETERS:

{B.Math.Vector3} position

RETURNS:

getPosition(result)

Returns the position vector.

PARAMETERS:

{B.Math.Vector3} [result]

omit if you want to return newly created vector

RETURNS:

extractScale(result)

Extracts scale factors.

PARAMETERS:

{B.Math.Vector3} [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.

PARAMETERS:

{B.Math.Angles} angles

RETURNS:

fromQuaternion(q)

Sets this matrix from a quaternion.

PARAMETERS:

RETURNS:

identity()

Sets this matrix to the identity.

RETURNS:

translation(x, y, z)

Sets this matrix to translation transform.

PARAMETERS:

{number} x

{number} y

{number} z

RETURNS:

rotationX(angle)

Sets this matrix to X-axis rotation transform.

PARAMETERS:

{number} angle

RETURNS:

rotationY(angle)

Sets this matrix to Y-axis rotation transform.

PARAMETERS:

{number} angle

RETURNS:

rotationZ(angle)

Sets this matrix to Z-axis rotation transform.

PARAMETERS:

{number} angle

RETURNS:

rotationAxis(axis, angle)

Sets this matrix to arbitrary axis rotation transform.

PARAMETERS:

{B.Math.Vector3} axis

{number} angle

RETURNS:

scale(x, y, z)

Sets this matrix to scale transform.

PARAMETERS:

{number} x

{number} y

{number} z

RETURNS:

lookAt(eye, target, up)

Sets this matrix to right-handed view transform.

PARAMETERS:

RETURNS:

orthographic(width, height, zNear, zFar)

Sets this matrix to orthographic projection transform.

PARAMETERS:

{number} width

{number} height

{number} zNear

{number} zFar

RETURNS:

perspective(fov, aspect, zNear, zFar)

Sets this matrix to perspective projection transform.

PARAMETERS:

{number} fov

field of view angle

{number} aspect

output surface width to height ratio

{number} zNear

{number} zFar

RETURNS:

add(matrix)

Adds a matrix to this matrix.

PARAMETERS:

{B.Math.Matrix4} matrix

RETURNS:

mulScalar(scalar)

Multiplies this matrix by a given scalar.

PARAMETERS:

{number} scalar

RETURNS:

mulMatrices(a, b)

Multiplies two given matrices and sets the result to this.

PARAMETERS:

RETURNS:

mul(value)

Multiplies this matrix by a given matrix or a scalar.

PARAMETERS:

{number | B.Math.Matrix4} value

RETURNS:

determinant()

Calculates the determinant of this matrix.

RETURNS:

{number}

transpose()

Transposes this matrix.

RETURNS:

invert()

Inverts this matrix.

RETURNS:

THROWS:

{Error}

if determinant is zero.

equal(matrix)

Checks for strict equality of this matrix and another matrix.

PARAMETERS:

{B.Math.Matrix4} matrix

RETURNS:

{boolean}

CONSTANTS:

PROPERTIES:

METHODS: