TITLE: Matrix operation for rotating all elements?
QUESTION [0 upvotes]: Is there a matrix operation that would allow me to rotate a matrix as if I was rotating surface it is on? For example: $$\begin{pmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{pmatrix} -> \begin{pmatrix}
3 & 6 & 9 \\
2 & 5 & 8 \\
1 & 4 & 7
\end{pmatrix}$$ would be a counter clockwise rotation by $\pi/2$ ?

REPLY [1 votes]: You want to do $$\begin{pmatrix}0&0&1\\0&1&0\\1&0&0\end{pmatrix}\begin{pmatrix}1&2&3\\4&5&6\\7&8&9\end{pmatrix}^T=\begin{pmatrix}0&0&1\\0&1&0\\1&0&0\end{pmatrix}\begin{pmatrix}1&4&7\\2&5&8\\3&6&9\end{pmatrix}=\begin{pmatrix}3&6&9\\2&5&8\\1&4&7\end{pmatrix}$$
{"set_name": "stack_exchange", "score": 0, "question_id": 3855395}