Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I have a 2D matrix as such: $$\begin{bmatrix} 1 &0 &0\\ 0 &1 &0\\ 0 &0 &1\\ \end{bmatrix} $$

If I apply a rotation of 180 degrees and a scale of 2, what will my resultant matrix look like? Also, given another matrix (example below), how do I get the angle it was rotated and the scale?

$$\begin{bmatrix} 1.4 &0.12 &0\\ -0.12 &1.4 &0\\ 0 &0 &1.0\\ \end{bmatrix} $$ I apologise in advance- I'm not a math major and this is most definitely not homework. I just want to apply this knowledge in transforming images (I'm making an app). Thanks!

share|cite|improve this question
Rotation about an anticlockwise angle $\theta$ is given by $\begin{pmatrix}\cos\,\theta&-\sin\,\theta\\\sin\,\theta&\cos\,\theta\end{pmatrix}‌​$, while scaling by a factor of $p$ in the horizontal and a factor of $q$ in the vertical is represented by $\begin{pmatrix}p&0\\0&q\end{pmatrix}$. So, in most cases, you have to specify the direction of rotation, and which of the two transformations will you be applying first. Luckily for you, since $p=q$ in your case, the order doesn't matter... – J. M. Feb 10 '12 at 14:17
"Also, given another matrix (example below), how do I get the angle it was rotated and the scale?" - you'll want to look up what is called the QR decomposition. – J. M. Feb 10 '12 at 14:22
thanks jm. so i guess getting the angle and scale is a pretty difficult process. what if we know that p and q will be the same all the time? – OckhamsRazor Feb 10 '12 at 14:33
If you know the matrix is always of the form $\begin{pmatrix}p\,\cos\,\theta&-p\,\sin\,\theta\\p\,\sin\,\theta&p\,\cos\,\theta‌​\end{pmatrix}$, then just take the square root of the sum of the squares of the entries in the first row to get $p$ (why?). Divide all the entries of the matrix by $p$ to obtain the rotation matrix. – J. M. Feb 10 '12 at 14:37
Obligatory xkcd: – Manishearth Feb 10 '12 at 15:47
up vote 1 down vote accepted

A= $\begin{bmatrix} 1 &0 &0\\ 0 &1 &0\\ 0 &0 &1\\ \end{bmatrix} $

B$_{+180}$= $\begin{bmatrix} cos(180 )&sin(180) &0\\ -sin(180) &cos(180 ) &0\\ 0 &0 &1\\ \end{bmatrix} $

C$_{2,2}$= $\begin{bmatrix} 2 &0 &0\\ 0 &2 &0\\ 0 &0 &1\\ \end{bmatrix} $

ABC = $\begin{bmatrix} -2 &0 &0\\ 0 &-2 &0\\ 0 &0 &1\\ \end{bmatrix} $ (Assuming rotation is clockwise)

share|cite|improve this answer
thanks. appreciate it. – OckhamsRazor Feb 11 '12 at 12:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.