Java Tetris - Using rotation matrix math to rotate piece I'm working on building tetris now in Java and am at the point of rotations...
I originally hardcoded all of the rotations, but found that linear algebra (matrix rotations) was the better way to go.
I'm trying to use a rotation matrix to rotate my pieces, and found I need a good understanding of trigonometry. 
I don't understand how $R(90^\circ)$ equals a rotation matrix of $R(-\theta)$ =` $$\begin{bmatrix}cos\theta &sin\theta \\-sin\theta & cos\theta\end{bmatrix}$$, aka $$\begin{bmatrix} 0 & 1 \\ -1& 0 \end{bmatrix}$$ (btw, if you know how to make a matrix on stackoverflow, please let me know). How does that equal a 90 degree rotation? Where do those zeros and ones come from? Moreover, how would that translate into code? I'm not looking for someone to code it for me, I'm looking for a concept with maybe a snippet of pseudocode.
I'm trying to visualize it with this drawing by putting the grid and tiles on a graph and drawing out the angles... but still don't understand it. 

Can anyone help?
Thanks!

Transposing

 A: The operations you are wanting to perform can be easily implemented without the need of rotation matrices since the transforms you desire are limited to right angle rotations and mirroring.
Assuming $B$ is a two dimensional array representing a block and $B[i,j]$ is the $i^{\text{th}}$ row and $j^{\text{th}}$ column of the block taking on values of 1 for a single block segment and 0 for an empty space.
The first operation you need is a transpose which is effectively a 90 degree clockwise rotation:
B T(B b)
    B b' <- new B[b.columns, b.rows]

    for i = 0 to b.rows - 1
        for j = 0 to b.columns -1
            b'[j,i] <- b[i, j]

    return b'

The second operation is mirroring a block about the y-axis:
B Y(B b)
    B b' <- new B[b.rows, B.columns]

    for i = 0 to b.rows - 1
        for j = 0 to b.columns - 1
            b'[i,j] <- b[i, b.columns - 1 - j]

    return b'

And finally, mirroring a block about the x-axis:
B X(B b)
    B b' <- new B[b.rows, B.columns]

    for i = 0 to b.rows - 1
        for j = 0 to b.columns - 1
            b'[i,j] <- b[b.rows - 1 - i, j]

    return b'

Given a block $B$ in a neutral position, a 90 degree clockwise rotation is $T(B)$, 180 is $T(X(T(B)))$, 270 is $Y(T(B))$ and 360 is simply $B$. counter clockwise rotations are just 360 minus the complementing clockwise rotations.
Also, as @StevenStadnicki pointed out in the comments, you can hard code much of this and you will find that if you are replicating the original Tetris, you'll encounter more that requires a hard coded solution than not.
