Why do you have a 3x3 transformation matrix when you only have a 2-d graph? The result of your transformation should be another 1x2 matrix, representing the new x and y, x' and y'. Also, you are performing 3 transformations. You are scaling, sliding and rotating, so I would use 3 separate 2x2 matrices, one for each transformation. You can combine them later, once you get it. As for the 3 matrices, here is how they work:
- Scaling: Your old x-axis length was pi/2. The new length needs pythagoreans theorem: sqrt((c-x1)^2 + (d-y1)^2). The scaling factor is new/old. You do similar for the y scaling factor.
- Rotation: You must figure out how much you rotated by. Make a right triangle with (x1,y1), (c,y1) and (c,d). Use the lengths of the sides to figure out theta, your angle of rotation.
- Translation: You moved to the right x1 units and up y1 units. You will add this number after you scale and rotate.
Your scaling matrix is just a diagonal. You multiply the x coordinate by the x scaling factor, and the y coordinate by the y scaling factor:
Code:
[x'] = [Sx 0] [x]
[y'] [0 Sy] [y]
Your rotation matrix looks like:
Code:
[x'] = [cos t -sin t] [x] where t is theta, your angle of rotation
[y'] [sin t cos t] [y]
And your translation matrix is a 1x2 matrix that you add instead of multiply:
Code:
[x'] = [x1] + [x]
[y'] [y1] [y]
Putting it all together, you get:
Code:
[x'] = [cos t -sin t] [Sx 0] [x] + [x1]
[y'] [sin t cos t] [0 Sy] [y] [y1]
At least, I'm pretty sure that's how you'd do it. Try taking some points with known cooridanates both before and after, and plug them to see if they transform correctly. Some "easy" known points are (0,0)-->(x1,y1), (0,1)-->(a,b) and (pi/2,0)-->(c,d).