3
$\begingroup$

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?

3 Answers 3

1

There is a kind of transformation that is not linear but it is simple and fits the job. It allows you to transform the unit square into an arbitrary quadrilateral.

$\pmatrix{x'\\y'} = \pmatrix{u_x&v_x&w_x\\u_y&v_y&w_y}\pmatrix{x\\y\\xy}$

$x'=u_xx+v_xy+w_xxy\\ y'=u_yx+v_yy+w_yxy$

It transforms the unit square in a way controlled by the vectors $u=(u_x,u_y), v=(v_x,v_y), w=(w_x,w_y)$ as follows:

Geometric interpretation of u, v, w

Note however that it's not a perspective transformation.

2

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

So a linear transformation will map any parallelogram to another parallelogram, because the opposite sides of a parallelogram form the same vector. As that does not hold for a trapezoid, a linear transformation cannot turn a rectangle (= special case of a parallelogram) into such a trapezoid that is not also a parallelogram.

  • 1
    I think that $3\times 3$ is fine.2012-07-11