# The correct order for applying transformations?

I had a line, y=-1/2 x

I wanted to reflect everything onto the line so as you can see by my steps in the picture below(sorry, I dont know the coding) I first rotated the line theta degrees then projected everything to that line and rotated it back.

I think maybe my triangle for the values of theta are incorrect...this is right at the top. The problem also might be the way I am applying these matrices. To do this, I am correct if my first transformation starts on the left, my second would follow on the right and so on.

As you can see my matrix for the FIRST rotation was on the right hand side(This was the counter clockwise rotation, so the rotation matrix stays the same. The only thing that caused a change is my triangle because putting sin(theta) into the matrix would give me a negative sin, and the negatives would cancel out.[ This all refers to my first transformation matrix]

None the less, I cannot understand where I've gone wrong. Could someone help me understand why my martrices differs from the ones right at the bottom.

Your diagram and rightmost matrix indicate that you have measured $\theta$ in the negative direction and are rotating input points by that $\theta$. In other words your right-most matrix rotates the $x$-axis onto your line. What you really want to do is first rotate by $-\theta$ so that points on your line are mapped to the $x$-axis. This will exchange your two rotation matrices, yielding the form you give in your unsourced image.
More on "negative direction": Angles are measured from the positive $x$-axis in the anti-clockwise direction around the origin. This means that an angle starting at measure zero and slowly increasing first passes through the first quadrant, then the second, then the third, then the forth, before returning to the positive $x$-axis. If we measure in the clockwise direction, it is normal to associate those measures with negative angles. An angle of measure $1 \,\text{rad}$ is in the first quadrant and an angle of measure $-1 \,\text{rad}$ is in the fourth quadrant.
You've measured $\theta$ in the fourth quadrant. (One way to see this is that your $\cos \theta > 0$ and your $\sin \theta < 0$, so you have placed $\theta$ in the fourth quadrant.) When you wrote your rotation matrices, the one on the right (the first one an incoming vector (on the right) gets multiplied by) rotates its input by $\theta$ around the origin. That is, it takes everything on the $x$ axis and rotates it onto the line you gave. What you actually want is to rotate everything by a small positive angle ($-\theta$) so that the points on your line would end up on the $x$-axis, then project down, then rotate everything back, by the small negative angle $\theta$. This exchanges your two rotation matrices, giving the product of matrices in the unsourced image you gave.