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


Where TM=Transformation Matrix

A=given coordinates

B=transformed coordinates enter image description here

  • $\begingroup$ 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)$/ $\endgroup$ Commented Mar 6 at 12:42
  • $\begingroup$ @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? $\endgroup$
    – barnyard9
    Commented Mar 6 at 13:45

1 Answer 1


I am not sure whether this is what you need, hope it helps:

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} $$

which takes translation, shearing, scaling and rotation into account. Since this representation has more unknown variables, it requires more information to solve the whole system.

  • $\begingroup$ Thanks for the support. $\endgroup$
    – barnyard9
    Commented Mar 8 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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