首页 > 其他 > 详细

Rotate Image

时间:2017-03-30 23:11:49      阅读:184      评论:0      收藏:0      [点我收藏+]

 

参照计算机图形学图形变换即可。

技术分享
public class Solution {
    
    public void rotate(int[][] matrix) {
        if(matrix.length<=1)return ;
        float dip=(float) ((matrix.length-1)/2.0);
        int[][] res=new int[matrix.length][matrix.length];
        for(int i=0;i<matrix.length;i++)
            for(int j=0;j<matrix.length;j++)
            {
                float x=i-dip;
                float y=j-dip;
                float newX=y+dip;
                float newY=-x+dip;
            //    System.out.println(newX+"    "+newY);
                res[(int)newX][(int)newY]=matrix[i][j];
            }
        for(int i=0;i<matrix.length;i++)
            for(int j=0;j<matrix.length;j++)
                matrix[i][j]=res[i][j];
    }
}
View Code

 

Rotate Image

原文:http://www.cnblogs.com/lichao-normal/p/6648718.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!