jStage.Matrix

Description

A set of functions that perform mathematical operations on 2x2 Matrices.

Hierarchy

Remarks

Though create(fx, fy, rx, ry) initializes a matrix as a 4-element Float32Array, any array object with four elements may be used with these functions. See tojicode.com for more information about this implementation.

Function List

Function Documentation

clone(mat)

Initializes a new Float32Array with four elements for use as a 2x2 matrix, taking it's initial values from another matrix object.

Parameters

mat:A compatible array-matrix object to clone.

Returns

A new Float32Array with four elements representing a 2x2 matrix.

copy(mat, out)

Sets the values of the given matrix to the values of another matrix.

Parameters

mat:The matrix object from which you're copying values.

out:The matrix object to which you're assigning values.

Returns

The matrix object passed as the out parameter.

create(fx, fy, rx, ry)

Initializes a new Float32Array with four elements for use as a 2x2 matrix.

Parameters

fx:The initial value for the top-left component.

fy:The initial value for the top-right component.

rx:The initial value for the bottom-left component.

ry:The initial value for the bottom-right component.

Returns

A new Float32Array with four elements representing a 2x2 matrix.

createIdentity()

Initializes a new Float32Array with four elements for use as a 2x2 matrix, with the initial values set as per the 2x2 identity matrix.

Returns

A new Float32Array with four elements representing a 2x2 matrix.

identity(out)

Sets the values of the given matrix to the 2x2 indentity matrix.

Parameters

out:The matrix object to which you're assigning the identity matrix values.

Returns

The matrix object passed as the out parameter.

rotate(mat, rad, out)

Rotates a coordinate system represented by a given matrix by a value in radians.

Parameters

mat:The matrix object with the values you're rotating.

rad:The amount, in radians, by which to rotate the given matrix.

out:The matrix object in which to store the rotation result.

Returns

The matrix object passed as the out parameter.