0

Hi. I have a Vector of Vectors that I need to rotate 90 degrees clockwise and 90 degrees counter-clockwise.

I got it to rotate Clockwise, but whatever I try, I can't get it to rotate counter clock-wise. The 2D Vector is not always going to be a square. It will mostly be a rectangle.

Can anyone help with the counter-clockwise rotation? everything that I've found only applies to Object[][]'s that are square...

Here is what I have to make it rotate CW successfully:

```
// tiles = Vector<Vector<MapTile>>();
public void rotateCW(){
int d1 = tiles.size();
int d2 = tiles.firstElement().size();
fieldHeight = d1;
fieldWidth = d2;
Vector v = new Vector<Vector<MapTile>>(d2);
for(int i=0;i<d2;i++){
Vector e = new Vector<MapTile>(d1);
for(int j=0;j<d1;j++){
e.add(tiles.get(d1-1-j).get(i));
}
v.add(e);
}
tiles = v;
rotation++;
if(rotation==4)rotation = 0;
}
```