# How to determine the transformation matrix from given initial and transformed co-ordinates?

How to determine transformation matrix for an object given a graph?

This is a problem indeed similar to this one. And I've approached it in the same way like there.

Given: A line AB A(0,0),B(1,1).

It is transformed to A'(0,-1),B'(-1,0)

Now, I need to find the transformation matrix.

I begin

TM.A=B

Where TM=Transformation Matrix

A=given coordinates

B=transformed coordinates

• So, what is your questions, specifically? Surely $TM\times A$ will not yield $B$ here. I think this actually requires a translation vector, which will not fit in a 2D matrix. You need 3D matrix (homogeneous coordinates), unless you are discussing transformation around point $(1/2, -1/2)$/ Commented Mar 6 at 12:42
• @Enigmatisms I know I did wrong because when I take a look at it and reverse multiply, I don't get the coordinates that I should be getting after getting transformed. Can you guide me just the matrix required? Commented Mar 6 at 13:45

To transform from one line to the other, one can try to use the homogeneous coordinates, which will incorporate the potential translation of the line. So we can formulate the problem in the following way. Notice that the length of the line stays the same, therefore we don't need to consider scaling. Thus, this case can be modeled as rigid body transformation: $$\begin{pmatrix} \cos\theta & -\sin\theta & t_x\\ \sin\theta & \cos\theta & t_y\\ 0 & 0 & 1\\ \end{pmatrix} \begin{pmatrix} 0 & 1\\ 0 & 1\\ 1 & 1\\ \end{pmatrix} = \begin{pmatrix} 0 & -1\\ -1 & 0\\ 1 & 1\\ \end{pmatrix}$$ Solving the above linear equations yields: $$\cos\theta = 0, \sin\theta = 1, t_x = 0, t_y = -1$$. So this tells us:
• Line AB is first rotated around $$(0, 0)$$ by 90$$\deg$$ (counter-clockwise), we have: CD $$(0, 0)\rightarrow(-1, 1)$$.
• Then we apply translation: CD -> A'B', moving the line down the y-axis by 1: $$(0, -1)\rightarrow(-1, 0)$$.
So basically, if you know it is gonna be rigid body transformation, then approach the problem in the above way. A more general 2D transformation will be (given in homogeneous coordinate system): $$\begin{pmatrix} a & b & c\\ d & e & f\\ 0 & 0 & 1\\ \end{pmatrix}$$