Tile [][] trans;  if(angle == ROTATE_90 || angle == ROTATE_270) { trans = new Tile[widthInTiles][heightInTiles]; } else { trans = new Tile[heightInTiles][widthInTiles]; }  double cos_angle = Math.round(Math.cos(Math.toRadians(angle))), sin_angle = Math.round(Math.sin(Math.toRadians(angle)));  for(int y=0;y<heightInTiles;y++){ for(int x=0;x<widthInTiles;x++) { int trans_x = x - widthInTiles/2; int trans_y = y - heightInTiles/2; trans[y][x] = getTileAt((int)(trans_x*cos_angle - trans_y * sin_angle)+widthInTiles/2,(int)(trans_x*sin_angle+trans_y*cos_angle)+heightInTiles/2); } } map = trans; }
Tile[][] trans; int xtrans = 0, ytrans = 0;  switch (angle) { case ROTATE_90: trans = new Tile[widthInTiles][heightInTiles]; xtrans = heightInTiles - 1; break; case ROTATE_180: trans = new Tile[heightInTiles][widthInTiles]; xtrans = widthInTiles - 1; ytrans = heightInTiles - 1; break; case ROTATE_270: trans = new Tile[widthInTiles][heightInTiles]; ytrans = widthInTiles - 1; break; default: System.out.println("Unsupported rotation (" + angle + ")"); return; }  double ra = Math.toRadians(angle); int cos_angle = (int)Math.round(Math.cos(ra)); int sin_angle = (int)Math.round(Math.sin(ra));  for (int y = 0; y < heightInTiles; y++) { for (int x = 0; x < widthInTiles; x++) { int xrot = x * cos_angle - y * sin_angle; int yrot = x * sin_angle + y * cos_angle; trans[yrot + ytrans][xrot + xtrans] = getTileAt(x, y); } }  widthInTiles = trans[0].length; heightInTiles = trans.length; map = trans; }
	public void rotate(int angle) {		Tile [][] trans;				if(angle == ROTATE_90 || angle == ROTATE_270) {			trans = new Tile[widthInTiles][heightInTiles];		} else {			trans = new Tile[heightInTiles][widthInTiles];		}				double cos_angle = Math.round(Math.cos(Math.toRadians(angle))), sin_angle = Math.round(Math.sin(Math.toRadians(angle)));				for(int y=0;y<heightInTiles;y++){					for(int x=0;x<widthInTiles;x++) {				int trans_x = x - widthInTiles/2;				int trans_y = y - heightInTiles/2;				trans[y][x] = getTileAt((int)(trans_x*cos_angle - trans_y * sin_angle)+widthInTiles/2,(int)(trans_x*sin_angle+trans_y*cos_angle)+heightInTiles/2);			}		}		map = trans;	}