# Is there a projection matrix for 2D to 1D perspective projection?

I was wondering, if there is a projection matrix for a perspective projection of a 2D point to a line.

E.g. a random point being projected to the line at $x=1$, parallel to the y axis in the direction of the origin $(0,0)$.

I know that the easiest way to compute this would be to solve the linear equation at $x=1$ (or the intersection of the lines), but isn't there be a matrix based solution too?

To be concrete: I'm looking for a matrix $A$, that solves the equation $x \rightarrow Ax$ with $A\in \mathbb{R}^{3\times3}$

To conclude Emilios answer below, the matrix I was looking for can be written as $$x\rightarrow Ax,\text{with }A= \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ \frac{1}{\text{intercept}_x} & \frac{1}{\text{intercept}_y} & 0 \end{bmatrix}$$

• I do not understand what you're looking for, could you perhaps add a sketch? Is it correct that you are given a line $ax+by+d=0$ and a point $(u,v)$ and you want to know what point on the line corresponds to the orthogonal projection of $(u,v)$ onto the line? – flawr Apr 1 '16 at 15:42
• I have expanded my question to be more precise, although Emilios answer below is exactly what I am looking for. – Corbie Apr 2 '16 at 13:20

## 1 Answer

If I well understand your question, the answer can be done using homogeneous coordinates.

Given a point $P=(a,b)$, his homogeneous coordinates are $P=[a,b,1]^T\equiv [ca,cb,c]^T$ ( see here for a definition).

using this the projection from the origin on the line $x=1$ can be represented by the matrix: $$A= \begin{bmatrix} 1&0&0\\ 0&1&0\\ 1&0&0 \end{bmatrix}$$ that gives: $$\begin{bmatrix} 1&0&0\\ 0&1&0\\ 1&0&0 \end{bmatrix} \begin{bmatrix} a\\ b\\ 1 \end{bmatrix}= \begin{bmatrix} a\\ b\\ a \end{bmatrix}\equiv \begin{bmatrix} 1\\ b/a\\ 1 \end{bmatrix}$$

For any $P=(a,b)$, the straight line from $O$ to $P$ has equation $y=\frac{b}{a}x$, so the point $P'$ of this line with $x=1$ has coordinates $P'=(1,\frac{b}{a})$

So, in homogeneous coordinates, the two points are represented as: $$P=\begin{bmatrix} a\\ b\\ 1 \end{bmatrix} \qquad P'=\begin{bmatrix} 1\\ b/a\\ 1 \end{bmatrix}=\begin{bmatrix} a\\ b\\ a \end{bmatrix}$$ and a simple inspection show that the matrix that transforms $P \to P'$ is the matrix $A$

• Yes, this is the matrix I am looking for. Could you please add how exactly you figured it out? – Corbie Apr 2 '16 at 13:35
• I've added to my answer. I hope it's useful :) – Emilio Novati Apr 2 '16 at 13:50
• Okay, does this mean, if you want to use any random line the third row of the matrix is [1/<x-intercept>, 1/<y-intercept>, 0]? – Corbie Apr 2 '16 at 14:26
• Yes, it's correct. – Emilio Novati Apr 2 '16 at 15:20