# How do projections in 3D with homogeneous coordinates work?

Affine 3D transformations can be expressed in homogeneous coordinates by a matrix $M \in \mathbb{R}^{4 \times 4}$. This means we have 16 parameters to calculate.

The first thing I asked myself is how many 3D points we need to define such a transformation.

Each point has 3 coordinates and thus each point gives 3 equations. I thought we would need

$$\left \lceil \frac{\overbrace{3 \cdot 3}^{\text{linear}} + \overbrace{3}^{\text{translation}}}{\underbrace{3}_{\text{equations per point}}} \right \rceil = 4$$

points to define $M$. However, I also realize we are speaking of a $4 \times 4$ matrix having 16 entries, not 12. I guess the remaining 4 entries are for the projection?

I thought the strucutre of the matrix was

$$\begin{pmatrix}A & t\\ \vec 0 & 1\end{pmatrix}$$

where $A \in \mathbb{R}^{3 \times 3}$ is a linear transformation, $t \in \mathbb{R}^{3 \times 1}$ is a transposition, $\vec 0 \in \mathbb{R}^{1 \times 3}$ is a 0-vector. But this would not project anything. I guess for projection the $\vec 0$ is replaced by something different? Is there a simple way to describe it?

Now I read slides of a computer graphics lecture which says

How many points define a 3D transformation uniquely?

$3 \times 4$ entries of a $4 \times 4$ matrix (linear part and translation) resulting in 12 unknowns, hence 4 points

[...]

A projection in 3D is defined by a mapping of 5 points in $\mathbb{R}^3$

• $4 \times 4$ matrix, but homogeneous coordinates are invariant to scaling
• $5 \times 3 = 4 \times 4 - 1$

Source: German slides by Prof. Dr. Ing. Carsten Dachsbacher for Computer Graphics. (I translated them for this question.)

Now I'm confused. Where those the "5" in the slides come from? Why $4 \times 4 - 1$?

• I'd call $t$ a translation vector, in order to confusion with transposition in the sense of transposing a matrix. – flawr Aug 1 '16 at 15:34

Let $M = \begin{pmatrix} A & t \\ b^t & 1 \end{pmatrix}$ be a transformation matrix. As you said, $b^t$ used for projections, and $b^t =0$ for affine transformations. Consider a point $p=(x,y,z)^t$ that we want to transform. Wer first write it in homogeneous coordinates as the vector $v = (p^t,1)^t$ The result $r$ of the transformation then is:

$$r=Mv = \begin{pmatrix}Ap+t\\b^t p+1\end{pmatrix}$$

If we want to get back a 3d point we have to divide by the last coordinate, and we get:

$$q = \frac{1}{b^tp+1} (Ap+t)$$

This is the crucial step that enables the scale invariance. Let us scale the transformation matrix by a factor $\lambda \neq 0$, and see what we get:

$$r' = \lambda Mv = \begin{pmatrix}\lambda Ap+\lambda t\\\lambda b^t p+\lambda\end{pmatrix}$$

In order to get back to the 3d coordinates we again divide by first three entries by the last entry and get

$$\frac{1}{\lambda b^t p + \lambda} (\lambda Ap + \lambda t) = \frac{\lambda}{\lambda} \frac{1}{b^t p+1} (Ap+t) = r$$

That is again the same result as without the scaling. So we can conclude that a transformation matrix describes the same transformation even after scaling it with a nonzero scalar. That is waht it means for $M$ to be scale invariant. As the bottom right entry cannot be zero (in the application of computer graphics at least, if you consider a more math related topic of projective geometry this does not necessarily have to be that way), we can just define it to be $1$. So in the end we have 15 degrees of freedom:

$$M = \begin{pmatrix} a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & 1\end{pmatrix}$$

Now how can you find those parameters?

For each vector $v_i = (x_i,y_i,z_i,1)^t$ with projection $v_i' = (x_i',y_i',z_i',z_i)^t$ the equation $v_i' = Mv_i$. Lets say you have really big number $v_i$ at hand. Then the equations $v_i' = Mv_i$ represent an overdetermined system of linear equations. So we have $15$ parameters that means we need 15 (linearly independent) equations. From each $v_i$ we get three equations, that means we need at least 5 $v_i'$ to determine our parameters (assuming they are distinct "enough", i.e. not collinear e.t.c).