   Rotating a 2D Array...    
  If I have a 4x4 array:0 0 0 00 0 0 00 0 0 10 1 1 1How do I rotate the data so that I end up with this:0 0 0 01 0 0 01 0 0 01 1 0 0Any help would be much appreciated, I've tried several things, but none seem to work.Jonoxon[edited by - Jonoxon on September 16, 2002 9:13:30 AM]
  Simply read each row as a colum instead.If you read the last first, then the second last etc you''ll have it rotated as you wish:0000100010001100;  To understand how and why that works, look up matrix transposition.    "With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I''m reaching up and reaching out. I''m reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one''s been. We''ll ride the spiral to the end and may just go where no one''s been." - Maynard James Keenan    [TheBlackJester   ][Wildfire Studios   ]    ;  OK, thanks. I''ll do that.Jonoxon  ;  it''s almost the tranpose. kind of the mirror of the transpose... why do u want to do that transform?  ;  OK, here's what I did, in C++ (it works)   int temp[4][4];int k=3;for(int i=0;i<4;i++){for(int j=0;j<4;j++){temp[i][j]=CurrentTet[j][k];}k--;}//Here I do collision checking, making sure that the rotation is valid etc.for(i=0;i<4;i++){for(int j=0;j<4;j++){CurrentTet[i][j] = temp[i][j];}}   The reason I want to do this transform is for something that no programmer would be complete without, my first Tetris clone. This function rotates the tetraminoes 90 degrees. Jonoxon[edited by - Jonoxon on September 16, 2002 12:01:01 PM];  It is not the tranpose of the matrix.For example the (3,4) entry, a 1, should be at (4,3) in the tranpose. But it isn''t, there''s a zero there. The transpose would be:0000000100010011  ;  i could apply the 2d rotation matrix:cos(t) -sin(t)sin(t) cos(t)where t is the rotation angle.  ;  The one I have works just fine. If you look you will see that I have a transposed matrix that has been mirrored(transposition causes the data to be mirrored anyway, so mirroring is necessary to maintain the original shape)Mirror  | Transpose0 0 0 0 | 0 0 0 01 0 0 0 | 0 0 0 11 0 0 0 | 0 0 0 11 1 0 0 | 0 0 1 1  Jonoxon  