Suppose I have rectangular 4x8 grid represented as an array of values in javascript:
var grid = [
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
];
How can I rotate this array -90 degrees to the left so that it then becomes an 8x4 grid?
I have tried toying with the solutions in other questions such as this one:
How to rotate a matrix in an array in javascript
But the answers only deal with square grids.
Any help would be greatly appreciated.