- Source: src/utils/array/matrix/index.js (Line 7)
Methods
-
<static> CheckMatrix( [matrix])
-
Checks if an array can be used as a matrix.
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Description matrix
Array.<Array.<T>> <optional>
The array to check.
- Since: 3.0.0
- Source: src/utils/array/matrix/CheckMatrix.js (Line 7)
Returns:
true
if the givenmatrix
array is a valid matrix.- Type
- boolean
-
<static> MatrixToString( [matrix])
-
Generates a string (which you can pass to console.log) from the given Array Matrix.
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Description matrix
Array.<Array.<T>> <optional>
A 2-dimensional array.
- Since: 3.0.0
- Source: src/utils/array/matrix/MatrixToString.js (Line 10)
Returns:
A string representing the matrix.
- Type
- string
-
<static> ReverseColumns( [matrix])
-
Reverses the columns in the given Array Matrix.
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Description matrix
Array.<Array.<T>> <optional>
The array matrix to reverse the columns for.
- Since: 3.0.0
- Source: src/utils/array/matrix/ReverseColumns.js (Line 7)
Returns:
The column reversed matrix.
- Type
- Array.<Array.<T>>
-
<static> ReverseRows( [matrix])
-
Reverses the rows in the given Array Matrix.
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Description matrix
Array.<Array.<T>> <optional>
The array matrix to reverse the rows for.
- Since: 3.0.0
- Source: src/utils/array/matrix/ReverseRows.js (Line 7)
Returns:
The column reversed matrix.
- Type
- Array.<Array.<T>>
-
<static> Rotate180( [matrix])
-
Rotates the array matrix 180 degrees.
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Description matrix
Array.<Array.<T>> <optional>
The array to rotate.
- Since: 3.0.0
- Source: src/utils/array/matrix/Rotate180.js (Line 9)
Returns:
The rotated matrix array. The source matrix should be discard for the returned matrix.
- Type
- Array.<Array.<T>>
-
<static> RotateLeft( [matrix])
-
Rotates the array matrix to the left (or 90 degrees)
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Description matrix
Array.<Array.<T>> <optional>
The array to rotate.
- Since: 3.0.0
- Source: src/utils/array/matrix/RotateLeft.js (Line 9)
Returns:
The rotated matrix array. The source matrix should be discard for the returned matrix.
- Type
- Array.<Array.<T>>
-
<static> RotateMatrix( [matrix] [, direction])
-
Rotates the array matrix based on the given rotation value.
The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command:
rotateLeft
,rotateRight
orrotate180
.Based on the routine from http://jsfiddle.net/MrPolywhirl/NH42z/.
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Default Description matrix
Array.<Array.<T>> <optional>
The array to rotate.
direction
number | string <optional>
90 The amount to rotate the matrix by.
- Since: 3.0.0
- Source: src/utils/array/matrix/RotateMatrix.js (Line 10)
Returns:
The rotated matrix array. The source matrix should be discard for the returned matrix.
- Type
- Array.<Array.<T>>
-
<static> RotateRight( [matrix])
-
Rotates the array matrix to the left (or -90 degrees)
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Description matrix
Array.<Array.<T>> <optional>
The array to rotate.
- Since: 3.0.0
- Source: src/utils/array/matrix/RotateRight.js (Line 9)
Returns:
The rotated matrix array. The source matrix should be discard for the returned matrix.
- Type
- Array.<Array.<T>>
-
<static> Translate( [matrix] [, x] [, y])
-
Translates the given Array Matrix by shifting each column and row the amount specified.
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Default Description matrix
Array.<Array.<T>> <optional>
The array matrix to translate.
x
number <optional>
0 The amount to horizontally translate the matrix by.
y
number <optional>
0 The amount to vertically translate the matrix by.
- Since: 3.50.0
- Source: src/utils/array/matrix/TranslateMatrix.js (Line 10)
Returns:
The translated matrix.
- Type
- Array.<Array.<T>>
-
<static> TransposeMatrix( [array])
-
Transposes the elements of the given matrix (array of arrays).
The transpose of a matrix is a new matrix whose rows are the columns of the original.
A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows. This is an example matrix:
[ [ 1, 1, 1, 1, 1, 1 ], [ 2, 0, 0, 0, 0, 4 ], [ 2, 0, 1, 2, 0, 4 ], [ 2, 0, 3, 4, 0, 4 ], [ 2, 0, 0, 0, 0, 4 ], [ 3, 3, 3, 3, 3, 3 ] ]
Parameters:
Name Type Argument Description array
Array.<Array.<T>> <optional>
The array matrix to transpose.
- Since: 3.0.0
- Source: src/utils/array/matrix/TransposeMatrix.js (Line 7)
Returns:
A new array matrix which is a transposed version of the given array.
- Type
- Array.<Array.<T>>