How to rotate a matrix in an array in javascript

后端 未结 4 1878
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 09:49

(disclosure, I\'m mostly math illiterate).

I have an array in this format:

var grid = [
  [0,0], [0,1], [0,2], [0,3],
  [1,0], [1,1], [1,2], [1,3],
          


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 10:11

    These are two function for clockwise and counterclockwise 90-degree rotation:

        function rotateCounterClockwise(a){
            var n=a.length;
            for (var i=0; i

提交回复
热议问题