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. 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 ]
]
name | type | arguments | description |
---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
The array to check. |
true
if the given matrix
array is a valid 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 ]
]
name | type | arguments | description |
---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
A 2-dimensional array. |
A string representing the 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 ]
]
name | type | arguments | description |
---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
The array matrix to reverse the columns for. |
The column reversed 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 ]
]
name | type | arguments | description |
---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
The array matrix to reverse the rows for. |
The column reversed 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 ]
]
name | type | arguments | description |
---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
The array to rotate. |
The rotated matrix array. The source matrix should be discard for the returned 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 ]
]
name | type | arguments | Default | description |
---|---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
The array to rotate. |
|
amount | number | <optional> | 1 |
The number of times to rotate the matrix. |
The rotated matrix array. The source matrix should be discard for the returned matrix.
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
or rotate180
.
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 ]
]
name | type | arguments | Default | description |
---|---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
The array to rotate. |
|
direction | number | string | <optional> | 90 |
The amount to rotate the matrix by. |
The rotated matrix array. The source matrix should be discard for the returned 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 ]
]
name | type | arguments | Default | description |
---|---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
The array to rotate. |
|
amount | number | <optional> | 1 |
The number of times to rotate the matrix. |
The rotated matrix array. The source matrix should be discard for the returned matrix.
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 ]
]
name | type | arguments | description |
---|---|---|---|
matrix | Array.<Array.<T>> | <optional> |
The array matrix to translate. |
x | number | <optional> |
The amount to horizontally translate the matrix by. |
y | number | <optional> |
The amount to vertically translate the matrix by. |
The translated matrix.
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 ]
]
name | type | arguments | description |
---|---|---|---|
array | Array.<Array.<T>> | <optional> |
The array matrix to transpose. |
A new array matrix which is a transposed version of the given array.