2次元回転行列
$ \begin{pmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \end{pmatrix}
$ \thetaが正の場合、反時計回り
覚え方
単位行列は$ \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}
$ \thetaが0のときはこれになっててほしいので、それでcosとsinはわかる
反時計回り90度回そうとすると、+Xにあったものが+Y・+Yにあったものが-Xに動きそうなので、
$ \begin{pmatrix} x' \\ y' \end{pmatrix} = \begin{pmatrix} -y \\ x \end{pmatrix} = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} x \\ y \end{pmatrix}
$ \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} 1 \\ 0 \end{pmatrix}
$ \begin{pmatrix} -1 \\ 0 \end{pmatrix} = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} 0 \\ 1 \end{pmatrix}
GLSLはColumn-majorです
code:glsl
mat2 rotate2D( float t ) {
float c = cos( t );
float s = sin( t );
return mat2( c, s, -s, c );
}