Here you can find the source of findAllPossibleRightRotations(int[][] matrix)
Parameter | Description |
---|---|
matrix | a parameter |
public static List<int[][]> findAllPossibleRightRotations(int[][] matrix)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**//from ww w. j av a 2 s . c o m * returns all 360 rotations in clock-wise in given matrix * @param matrix * @return */ public static List<int[][]> findAllPossibleRightRotations(int[][] matrix) { List<int[][]> allPossibleRotations = new ArrayList<>(); for (int i = 0; i < 3; i++) { matrix = rotateClockWise(matrix); allPossibleRotations.add(matrix); } return allPossibleRotations; } /** * rotates the matrix to clock wise * @param pixels * @return */ public static int[][] rotateClockWise(int[][] theArray) { int[][] rotate = new int[theArray[0].length][theArray.length]; for (int i = 0; i < theArray[0].length; i++) { for (int j = 0; j < theArray.length; j++) { rotate[i][theArray.length - 1 - j] = theArray[j][i]; } } return rotate; } }