3
$\begingroup$

What is Homogeneous Coordinates? Why is it necessary in 2D transformation of objects in computer graphics?

The concept of homogeneous coordinates in effect converts the 2D system a 3D one.

So, why don't we just use a 3D system instead?

$\endgroup$
  • 1
    $\begingroup$ So you're asking a new question by editing an old one? $\endgroup$ – graydad Jun 27 '15 at 15:54
  • $\begingroup$ It's not good to delete your old question and write a new question in its place, because now @graydad's careful answer to your original question won't be useful to other people. $\endgroup$ – littleO Aug 7 '15 at 7:24
4
+50
$\begingroup$

What is Homogeneous Coordinates? Why is it necessary in 2D transformation of objects in computer graphics?

Short version: Homogenous coordinates for a $n$-dimensional space consist of tuples with $n+1$ coordinates, where the extra coordinate is kept at a special value (one says it is normalized).
The extra dimension for matrices and vectors allows to model $n$-dimensional affine transformations as $(n+1)\times (n+1)$ matrices acting on $n+1$-dimensional vectors.

Many of the useful transformations in 2D or 3D graphics are affine transformations, not linear. To still be able to use the convenient matrices one can use homogeneous coordinates in $3$ or $4$ dimensions, where the last coordinate is normalized to $1$.

The convenience comes from the fact that often basic transformations (rotations, scalings, translations, mirror operations, shearings, ..) are chained to build up a complex transformation. Each basic transformation is represented by a matrix $T_i$, the matrix $T$ of the result transformation is simply the matrix product of the matrices of the basic transformations. $$ T = T_1 T_2 \cdots T_m $$ It is not necessary, but makes life easier.

Your example is translation by a constant vector $t$: $$ T(x) = x + t = A x $$ for some square transformation matrix $A$. So you want $$ \left( \begin{matrix} x + t_x \\ y + t_y \\ 1 \end{matrix} \right) = \left( \begin{matrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{matrix} \right) \left( \begin{matrix} x \\ y \\ 1 \end{matrix} \right) = \left( \begin{matrix} a_{11} x + a_{12} y + a_{13} \\ a_{21} x + a_{22} y + a_{23} \\ a_{31} x + a_{32} y + a_{33} \end{matrix} \right) $$ These are two linear equations for the $x$ and $y$ coordinates and a third one for the extra coordinate.

Comparing the elements on the LHS with the ones from the RHS gives the matrix coefficients $a_{ij}$.

So the third column gives the constant parts, annd should be $(t_x, t_y, 1)^\top$. Where no $x$ is needed the $a_{1j} = 0$, then where $x$ is needed the scaling is $1$ and results in $a_{1j}=1$. So we need $x$ in row $1$ but not in $2$ and $3$. Similar reasoning for $y$. That procedure is straight forward and results in all $9$ coefficients of the matrix $A$.

The concept of homogeneous coordinates in effect converts the 2D system a 3D one.

So, why don't we just use a 3D system instead?

It is unclear what you mean by 3D system.

If you use homogenous coordinates for 2D graphics, then you end up using 3D vectors and 3D matrices. But you will use them for 2D affine transformations on 2D vectors represented by 3D vectors and not for arbitrary 3D graphics operations.

If you use homogenous coordinates for 3D graphics, then you end up using 4D vectors and 4D matrices. But you will use them for 3D affine transformations on 3D vectors represented by 4D vectors.

Again: You invest another dimension to reap algebraic convenience.

$\endgroup$
4
$\begingroup$

You gotta work backward to find this matrix. First convince yourself that there is no $2\times 2$ matrix $A$ such that $$ A\left[\begin{array} &x \\ y \end{array}\right] = \left[\begin{array} &x+t_x \\ y+t_y \end{array}\right]$$ This is because you need $A$ to have a couple $1$'s, and a $t_y$, $t_x$. But you also need a few zeroes. So you move up a size of matrix to a $3\times3$. To facilitate this, you add a redundant equation $1=1$ to your two equations. A $3\times3$ matrix (we'll call $B$) may have enough space to have everything we need. So suppose $$B = \left[\begin{array} &a&b&c \\ d&e&f \\ h&i&j \end{array}\right]$$ Then compute $$B\left[\begin{array} &x \\ y \\ 1 \end{array}\right] $$ It also might be inherently obvious to you after multiplication that $a=1$, $b=0$, $c = t_x$ etc. If not, you can solve for $a$ through $j$ using your two initial equations and the redundant $1=1$. As you will find, such a matrix $B$ exists, and it works. So we go with it. Assuming the existence of something in this way is often called making an "ansatz."

$\endgroup$
  • $\begingroup$ Now, you have come to the point. So, there is actually no direct way of derivation of the matrix. We have to do it reverse and in that case we will have to start with some intuition. $\endgroup$ – user6704 Jun 26 '15 at 3:25
  • $\begingroup$ @BROY you got it. Assume it exists, deduce what the structure would look like if it exists. Then fill in the gaps with the information you already have until you realize you can piece all of it together. $\endgroup$ – graydad Jun 26 '15 at 3:34
3
$\begingroup$

It turns out that a not all standard transformations are linear. If a translations, in particular, are not linear. In order to represent a translation by matrix multiplication, we cannot use a $2\times 2$ matrix. We have to go up a dimension. To do this we extend the vector $(x,y)^T$ to $(x,y,1)^T$, where the $1$ is just a placeholder. This works out really well for the equations. We make a $3\times 3$ matrix with a 1 in the bottom right element, and zeros in the other elements on the bottom row. If we just put the translation amounts in the last column, we have constructed a matrix which maps $(x,y,1)^T$ to $(x',y',1)^T$ in exactly the way we want. We just take the first two elements of the result for the translated vector.

This method is even more powerful; we could replace the top left four elements could be any $2\times 2$ matrix which would represent the action of that matrix followed by a translation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy