# 2D transformation matrix to make a trapezoid out of a rectangle

In most vector graphic software libraries I can use (3x3) matrices to transform 2D geometry (e.g. scale, rotate, skew). How does a matrix need to look like to transform a 2D rectangle to a symmetrical trapezoid (or equilateral triangle if parameters are taken to the extreme)? What parts of the matrix define which parameters?

-

If you are looking for a transformation determined by multiplication with a 2x2 matrix, then I'm afraid this cannot be done. Such a transformation is linear, so maps a vector to the same vector irrespective of its starting points. In other words, if $A,B,C,D$ are points on the plane such that $\vec{AB}=\vec{CD}$, and $A',B',C',D'$ are their respective images under this transformation, then we also have $\vec{A'B'}=\vec{C'D'}$.
A 3D-rectangle OTOH will often look like a trapezoid, when it is projected to the plane of the monitor. That is because its coordinates will be divided by the distance (IIRC often the $z$-coordinate gets that role), because in the projection a point is moved along a line of sight starting from the origin. –  Jyrki Lahtonen Jul 10 '12 at 19:54
You can use a projective transformation. I would go to homogeneous coordinates, and use a suitable $3\times 3$ matrix. With the right matrix, one can transform any quadrilateral into any other quadrilateral. This is a relatively standard computer vision problem, and there must be modern implementations. –  André Nicolas Jul 10 '12 at 20:00