Transforming a square into a parallelogram

4.8k Views Asked by At

as an exercise I wanted to calculate the transformation matrix in order to make the square $ABCD$ into the parallelogram $A'B'C'D'$. I am able to get the matrix so that the square is first at the center $(0,0)$ and rotate it there that $A$ is at the same place as $A'$. But then I need to make the square to into a parallelogram. How can I calculate this matrix? The square at $(0,0)$ has coordinates from $-1.5$ to $1.5$.

Picture

Can anybody help me out?

3

There are 3 best solutions below

0
On

It is sufficient if you add to the component $x$, for example, some dependence on the $y$ component. Let's say if you matrix is something like \begin{array}{cc} 1 & a \\ 0 & 1 \end{array}

then, the $y$ component of your square will remain the same, but the $x$ will be shifted $\pm 1.5a$, depending if it is the upper side or the lower one of the square.

0
On

The transformation is a translation $T$ and a projection $P$.

You can determine the terms of $P$ by looking at $P(B-A)$.

Each unit step in $x$ gives $1/3$ of $B' - A'$, so the first column is $(-1/3, -2/3)$.

Similar for $P(C-B)$ we find that the second column of $P$ is $(1, 0)$.

The rest is just a translation vector, which you can determine from $T = P(A)- A' = (-6, 2)$

3
On

I would imagine do it in several steps, i.e. multiple transformation matrix multiply together. Not showing matrix as I don't know whether you know Homogeneous Coordinates for better matrix multiplication.

  1. Translate the original square to be centered at origin. $(-7.5, -3.5)$
  2. Rotate the square 90 degrees so that $A$ is on the top left hand corner
  3. Scale up x direction $4.5/3$
  4. Scale down y direction $2/3$
  5. Apply x direction shear transformation (described in seoanes's answer)
  6. Translate again to the final position. $(-6, -2.5)$