# What is exactly the third component in homogeneous coordinate system?

I was reading the wiki article about homogeneous coordinates , I learned that it has it's advantages when it comes to performing affine transformation, since you can represent it only matrices. But I couldn't understand what is the additional third component compared to Cartesian coordinates. In the image below we see additional 1(which I am trying to understand) added to convert it to homogeneous coordinates. • I don't understand your question. It seems to be saying that you read about homogeneous coordinates, but you don't actually know what they are or do or what their purpose is. Which would imply that you absorbed nothing from the article save the fact that they add an extra coordinate. Can you be more specific about what you do understand and what you do not? Mar 20 at 15:24
• computergraphics.stackexchange.com/questions/6271/… Mar 28 at 20:15

To understand the $$w$$ component, it'll be easier to understand how homogeneous coordinates come about in the first place. The following example will be in 2D for the sake of simplicity, but the same can be extended to 3D. Let's try to "invent" homogeneous coordinates for the first time.

We start with the high school line equation, $$ax + by + c = 0$$. This line lies on a 2D plane (or more formally, in $$\mathbb R^2$$). We can quite easily see that a point $$x$$ in $$\mathbb R^2$$, represented by $$x = [x_1, x_2]$$, lies on our line if the line equation still holds (i.e., $$ax_1 + bx_2 + c = 0$$). Notice that our "line" is really just defined by the values $$a$$, $$b$$, and $$c$$, so lets write that in row-vector form: $$l =[a\ b\ c]$$. Let us define this 3-component vector that represents our line in 2D as our "homogeneous representation" of a line in 2D space. This is the first building block of our "homogeneous coordinates" system.

To test if a point lies on this line line, we're really just doing component-wise multiplication between $$l$$ and $$x$$, ($$a \times x_1 + b \times x_2 + ... = 0$$), so we can now re-write our line equation as a dot product of $$x$$ and $$l$$ if we add a 1 as the 3rd component of our 2D points: $$x' = [x_1, x_2, 1]$$. Now:

$$l.x' = [a\ b\ c] \left[ \begin{array}{c} x_1\\ x_2\\ 1 \end{array} \right] = ax_1 + bx_2 + c = 0$$

That gets us back our original line equation exactly! Now we call our new 3-component point $$x'$$ as the normalized homogeneous representation of a 2D point. That "1" in the third component is the so called $$w$$ component. You might also have noticed that lines and points are not distinguished here. This is true in homogeneous coordinates, lines and points are duals of each other.

We can also see that it doesn't matter what are the exact values of $$a$$, $$b$$, and $$c$$ (or conversely, $$x_1, x_2, w$$), but rather it is the 2 independent ratios ($$a : b$$ and $$b : c$$) that really matters. In other words,

$$w(ax_1 + bx_2 + c) = 0$$

will hold for all values of $$w$$ (except for $$w = 0$$ for reasons to be explained later). This means that in our homogeneous coordinate system, the following all represents the same point:

$$w \left[ \begin{array}{c} x_1\\ x_2\\ 1 \end{array} \right] \equiv \left[ \begin{array}{c} x_1\\ x_2\\ 1 \end{array} \right] \equiv \left[ \begin{array}{c} wx_1\\ wx_2\\ w \end{array} \right]$$

By now, we've defined a new homogeneous coordinate system with a point $$x'$$ in this coordinate system. How do we get back $$x$$, the original 2D point? I hope it is simple to see that we just have to divide by $$w$$ and drop the $$w$$ component to get back the original point (this is in fact, "perspective division"!).

$$x = \left[ \begin{array}{c} x_1/w\\ x_2/w\\ \end{array} \right]$$

Notice how we can't divide by $$w$$ if $$w = 0$$? As a side note, this property is actually exploited in projective space, for us to represent points at infinity by having 0 in the $$w$$ component. In computer graphics, we also exploit this to represent vectors. You cannot get back a 2D point from a vector in homogeneous coordinates, which makes sense.

So to answer the original question of "what is the $$w$$ component?", it is just a scale factor for homogeneous coordinates. It may or may not be 1, but if it isn't 1, you have to normalize it by dividing the $$w$$ component as described above.

The relationship between standard coordinates $$(x,y)$$ and homogeneous coordinates $$(X,Y,Z)$$ is $$x = X / Z, y = Y/Z$$. Homogeneous coordinates are a type of projective coordinates. All points on the line $$(Z x, Z y, Z)$$ are equivalent to the point $$(x,y)$$ in 2D (the same thing can be applied for 3D). So technically 2D points are represented as 3D lines passing though the origin, and 2D lines are represented as 3D planes passing through the origin.

In computer graphics the above interpretation is largely irrelevant, however, since homogeneous coordinates are used mostly for convenience. A translation is of the form $$x' = x+t_x, y' = y+t_y$$. If one uses homogeneous coordinates, then this can be achieved through $$X' = 1 \cdot X + 0 \cdot Y + t_x \cdot Z$$, $$Y' = 0 \cdot X + 1 \cdot Y + t_y \cdot Z$$, and $$Z' = 0 \cdot X + 0\cdot Y + 1 \cdot Z$$. If you set $$Z=1$$ then you get exactly the expression for translation, and you can use the matrix induced from the 3 equations above. For directions you can set $$Z=0$$ so that translation would not be applied to those.

In 3D the homogeneous coordinates $$W$$ also plays a role in the perspective projection, since the projection matrix modifies it to hold the relevant value by which the other coordinates must be divided, and the division is typically carried out by the hardware.