Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Usually affine transform matrix (in 2D) is represented like

enter image description here

where block A is responsible for linear transformation (no translation) and block B is responsible for translation.

Block D is always zero and block C is always one.

What if I put some values into blocks D and C I will affect only third (bottom) component of 2D vector, which should be always 1 and usually plays no role.

But can it? Are there some generalizations, where third component plays some role and consequently, bottom row of transform matrix also does?

And one more question: does this decomposition is actual only for 2D? Is it the same for 2D and xD?

share|cite|improve this question

The problem

When handling affine transformations in 2D with these $3\times3$ matrices, you're embedding the usual 2D plane in 3D as $\left\{ \left.\begin{pmatrix}x\\y\\1\end{pmatrix}\right|x,y\in\mathbb{R}\right\}$, otherwise known as “the plane $z=1$”. The role of the bottom row of an affine transformation matrix $\begin{pmatrix}a_{11} & a_{12} & t_{1}\\a_{21} & a_{22} & t_{2}\\0 & 0 & 1\end{pmatrix}$ is to make sure that a point in the plane $z=1$ is mapped to another point in the same plane. If you were to change the bottom row, you'd usually end up with a point outside of the plane $z=1$, and you probably wouldn't know how to map it back to a point in the usual 2D plane.

Another perspective

However, there is a trick/another way of looking at this situation. You see, the plane $z=1$ has the nice property that every one of its points lies on exactly one line through the origin in 3D, and “most” lines through the origin pass through the plane $z=1$. Moreover, every point in 3D except for the origin lies on exactly one line through the origin, and most of them lie on a line that passes through the plane $z=1$. So what we can usually do, when we have a point not in the plane $z=1$, is follow the line through the origin until we get to the plane $z=1$ and then we know what the corresponding 2D point would be.

Algebraically, if $c\ne0$ and we are considering $\begin{pmatrix}a\\b\\c\end{pmatrix}$, we can divide by $c$ to get $\begin{pmatrix}a/c\\b/c\\1\end{pmatrix}$. That makes it reasonable to associate $\begin{pmatrix}a\\b\\c\end{pmatrix}$ with the 2D point $\left(\dfrac{a}{c},\dfrac{b}{c}\right)$ when $c$ is nonzero. Since they'll represent the same 2D point, I'll use $\sim$ to denote when one triple is a nonzero multiple of another: e.g. $\begin{pmatrix}a\\b\\c\end{pmatrix}\sim\begin{pmatrix}a/c\\b/c\\1\end{pmatrix}$.

Modifying the 1

This immediately allows us to interpret modifications of the $1$ in the lower right corner of the affine transformation matrix. If $\lambda\ne0$, $$\begin{pmatrix}a_{11} & a_{12} & t_{1}\\a_{21} & a_{22} & t_{2}\\0 & 0 &\lambda\end{pmatrix}\begin{pmatrix}x\\y\\1\end{pmatrix}=\lambda\begin{pmatrix}\dfrac{a_{11}}{\lambda} & \dfrac{a_{12}}{\lambda} & \dfrac{t_{1}}{\lambda}\\\dfrac{a_{21}}{\lambda} & \dfrac{a_{22}}{\lambda} & \dfrac{t_{2}}{\lambda}\\0 & 0 & 1\end{pmatrix}\begin{pmatrix}x\\y\\1\end{pmatrix}\sim\begin{pmatrix}\dfrac{a_{11}}{\lambda} & \dfrac{a_{12}}{\lambda} & \dfrac{t_{1}}{\lambda}\\\dfrac{a_{21}}{\lambda} & \dfrac{a_{22}}{\lambda} & \dfrac{t_{2}}{\lambda}\\0 & 0 & 1\end{pmatrix}\begin{pmatrix}x\\y\\1\end{pmatrix}\text{.}$$ Therefore, in our convention for interpreting 3D points, modifying the $1$ just scales the entries that do the affine transformation by a constant amount.

Modifying the 0s

Similarly, we can examine what happens when we modify the $0$s in the bottom row. As a special case, when there is no affine transformation at all, we have $$\begin{pmatrix}1 & 0 & 0\\0 & 1 & 0\\p_{x} & p_{y} & 1\end{pmatrix}\begin{pmatrix}x\\y\\1\end{pmatrix}=\begin{pmatrix}x\\y\\p_{x}x+p_{y}y+1\end{pmatrix}\sim\begin{pmatrix}\dfrac{x}{p_{x}x+p_{y}y+1}\\\dfrac{y}{p_{x}x+p_{y}y+1}\\1\end{pmatrix}$$

The last step is valid for most points, where $p_{x}x+p_{y}y+1\ne0$. Because of this scaling, points that started close to the line $p_{x}x+p_{y}y+1=0$ end up dilated (away from the origin), and points that started far away from the line end up contracted (towards the origin). This is not an affine transformation, but a standard type of “perspective transformation” (sometimes called “perspective projection”).

General Case

In the fully general case, we have the following complicated expression:

$$\begin{pmatrix}a_{11} & a_{12} & t_{1}\\a_{21} & a_{22} & t_{2}\\z_{1} & z_{2} &j\end{pmatrix}\begin{pmatrix}x\\y\\1\end{pmatrix}=\begin{pmatrix}a_{11}x+a_{12}y+t_{1}\\a_{21}x+a_{22}y+t_{2}\\z_{1}x+z_{2}y+j\end{pmatrix}\sim\begin{pmatrix}\dfrac{a_{11}x+a_{12}y+t_{1}}{z_{1}x+z_{2}y+j}\\\dfrac{a_{21}x+a_{22}y+t_{2}}{z_{1}x+z_{2}y+j}\\1\end{pmatrix}$$ The last step is valid where $z_{1}x+z_{2}y+j\ne0$. Because of this scaling, points that started close to the line $z_{1}x+z_{2}y+j=0$ end up dilated after the affine transformation is performed, and points that started far away from the line end up contracted after the affine transformation. For example, $\begin{pmatrix}1 & 0 & -1.9\\0 & 1 & -1.33\\-0.33 & 0.54 & 1.3\end{pmatrix}$ takes a “dog” with many right angles to a warped dog with none (the dashed line is $z_{1}x+z_{2}y+j=0$).

dog and transformed dog

You can explore these sorts of transformations interactively at . Unfortunately, if you don't have Mathematica, you'll need the Wolfram CDF player which is large and does not work with Chrome (but should work with Firefox, I believe).

Assorted Side Notes

  • If $j\ne0$, note that: $$\begin{pmatrix}\dfrac{a_{11}x+a_{12}y+t_{1}}{z_{1}x+z_{2}y+j}\\\dfrac{a_{21}x+a_{22}y+t_{2}}{z_{1}x+z_{2}y+j}\\1\end{pmatrix}=\left(\dfrac{1}{j}\begin{pmatrix}a_{11} & a_{12} & t_{1}\\a_{21} & a_{22} & t_{2}\\z_{1} & z_{2} & j\end{pmatrix}\right)\begin{pmatrix}x\\y\\1\end{pmatrix}$$ so nearly all possible “generalized affine transformations” of this form can use a $1$ in the lower right entry, if we like.
  • All of the above discussion extends just fine to higher dimensions, and it's in fact used often in computer graphics calculations one dimension higher (See, for example, ).
  • Finally, there's a lot of beautiful mathematics involved in not throwing away the points $\begin{pmatrix}a\\b\\0\end{pmatrix}$. They're kind of like “points infinitely far from the origin where parallel lines can meet”. You get the “real projective plane”, sometimes called the “extended Euclidean plane”. The sorts of coordinates we're using where we don't care about multiples are called “homogeneous coordinates” in general.
share|cite|improve this answer

Engineers (especially in the field of image processing and computer vision) used to represent an affine transformation in the stated form so that one can perform an affine transform using a single matrix-vector multiplication: $$ \begin{pmatrix}x'\\y'\\1\end{pmatrix} =\begin{pmatrix}a_{11}&a_{12}&t_1\\a_{21}&a_{22}&t_2\\0&0&1\end{pmatrix} \begin{pmatrix}x\\y\\1\end{pmatrix}. $$ Another merit of this representation is that you can compose two affine transformations using simply by multiplying their matrices together.

This representation obviously generalizes to higher dimensions as well, and it is a widely adopted convention to represent affine transformations in 2 or 3 dimensions in this way. Whether such a convention is good or not is a matter of taste, but engineers and computer scientists seem to think that this is convenient.

share|cite|improve this answer
But what about block D and C? – Suzan Cioc Mar 20 '13 at 16:24
@SuzanCioc What do you mean? $D$ remains a row of zeros and $C=1$ in all dimensions. – user1551 Mar 20 '13 at 17:09
What if I put non-zeros and non-ones there. This is the question. – Suzan Cioc Mar 20 '13 at 17:23
@SuzanCioc It's OK to put other entries in $C$ or $D$, as long as you do not compose affine transforms. Changing $C$ and $D$ will not change the results of $x'$ and $y'$. So, if all you need are only the $x,y$-coordinates of the outputs of a given affine transform, $C$ and $D$ don't play any roles in the calculation. However, if you do want to compose a number of affine transformations, you shall keep $C=0$ and $D=1$, or else a wrong result may be obtained. – user1551 Mar 20 '13 at 17:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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