fromArray

fun fromArray(array: ReadonlyArray<Double>, startingIndex: Int? = definedExternally, result: Matrix4? = definedExternally): Matrix4(source)

Creates a Matrix4 from 16 consecutive elements in an array.

// Create the Matrix4:
// [1.0, 2.0, 3.0, 4.0]
// [1.0, 2.0, 3.0, 4.0]
// [1.0, 2.0, 3.0, 4.0]
// [1.0, 2.0, 3.0, 4.0]

const v = [1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0];
const m = Matrix4.fromArray(v);

// Create same Matrix4 with using an offset into an array
const v2 = [0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0];
const m2 = Matrix4.fromArray(v2, 2);

Return

The modified result parameter or a new Matrix4 instance if one was not provided.

Parameters

array

The array whose 16 consecutive elements correspond to the positions of the matrix. Assumes column-major order.

startingIndex

The offset into the array of the first element, which corresponds to first column first row position in the matrix. Default value - 0

result

The object onto which to store the result.

See also