<p>Given your equations (which i just assume are correct):
<span class="math-container">$$
\begin{align}
x_p &amp;= x \frac{z_{vp}-z_{prp}}{z-z_{prp}}+x_{prp} \frac{z-z_{vp}}{z-z_{prp}}\\
y_p &amp;= y \frac{z_{vp}-z_{prp}}{z-z_{prp}}+y_{prp} \frac{z-z_{vp}}{z-z_{prp}}
\end{align},
$$</span></p>

<p>if we take <span class="math-container">$(x_{prp}, y_{prp}, z_{prp}) = (0, 0, 0)$</span>, then we have</p>

<p><span class="math-container">$$
\begin{align}
x_p &amp;= x\frac{z_{vp}}{z}\\
y_p &amp;= y\frac{z_{vp}}{z}
\end{align}
$$</span></p>

<p>Assuming the projection plane is at distance <span class="math-container">$d$</span> from the origin, and, by your drawing, that the projection plane is on the negative side of the Z axis, we have <span class="math-container">$z_{vp} = -d$</span>, which leads to</p>

<p><span class="math-container">$$
\begin{align}
x_p &amp;= - x\frac{d}{z}\\
y_p &amp;= - y\frac{d}{z}
\end{align}
$$</span></p>

<p>Now we can follow the same reasoning (homogeneous coordinates) as <a href="https://computergraphics.stackexchange.com/questions/8255/finding-the-projection-matrix-for-one-point-perspective">in my answer to your other question</a> (using column notation) to write</p>

<p><span class="math-container">$$
\begin{align}
\begin{bmatrix}
x\\y\\z\\ \frac{-z}{d}
\end{bmatrix}
=
\begin{bmatrix}
1&amp;0&amp;0&amp;0\\
0&amp;1&amp;0&amp;0\\
0&amp;0&amp;1&amp;0\\
0&amp;0&amp;\frac{-1}{d}&amp;0
\end{bmatrix}
\begin{bmatrix}
x\\y\\z\\1
\end{bmatrix}
\end{align}
$$</span></p>

<p>which after the division by the last coordinate will give the projected point. Notice that because we are writing it in column notation, the perspective matrix is the transpose of the matrix in your <a href="https://computergraphics.stackexchange.com/questions/8255/finding-the-projection-matrix-for-one-point-perspective">other question</a>. Also, the negative sign is because the camera reference frame is a right-handed one.</p>

<p>As for the second textbook that you are reading, I cannot understand why you would have a negative sign only in the x axis without knowing more about the camera reference frame. By the diagram you posted, there should not be a negative sign.</p>

CC BY-SA 4.0
2018-11-15T06:41:59.427Z
thank you for answering here as well, one user pointed out that the negative sign  was due to reflection on the yz plane to correct  the reference frame.... so the x coord was reflected was what he said.
mathmaniage
CC BY-SA 4.0
2018-11-15T06:43:48.467Z
if you have some time, could you please take a look at [this question of mine](https://computergraphics.stackexchange.com/questions/8262/preserving-z-values-during-projection) , I  can't  really seem to understand the given explanation.
mathmaniage
CC BY-SA 4.0
2018-12-06T12:29:13.430Z
Sorry for taking me so long to answer your comment. Another user has already answered your question, and it seems to be correct. If you just apply the perspective matrix as shown above, every z-value will map to d, losing the information about object ordering, which is needed for the Z-buffer algorithm to correctly render the scene. So, the original range of Z values is usually mapped to another range, such that after perspective projection, Z is mapped to normalized device coordinates, as expected by your graphics API of choice.
vgs
CC BY-SA 4.0
2018-11-14T16:40:37.993Z
2018-11-14T16:40:37.993Z
vgs
<p>In one text,  the  derivation for  perspective  projection  goes like  this:   <a href="https://i.sstatic.net/ZHCE0.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZHCE0.jpg" alt="image1"></a></p>

<p>If <span class="math-container">$x',y',z'$</span> represent any point along  the  projection line,and <span class="math-container">$x_{prp},y_{prp},z_{prp}$</span> are the projection reference point, then:</p>

<p><span class="math-container">$$x'=x-(x-x_{prp})u$$</span><br>
 <span class="math-container">$$y'=y-(y-y_{prp})u$$</span>
<span class="math-container">$$z'=z-(z-z_{prp})u$$</span>
where <span class="math-container">$0\le u \le 1$</span>  </p>

<p>Now,   finding the value of u from the third equation above and  replacing in the first and  second  equations,   we get at  <span class="math-container">$z_vp$</span>:</p>

<p><span class="math-container">$$ x_p=x'= x.\frac{z_{vp}-z_{prp}}{z-z_prp}+x_{prp}.\frac{z-z_{vp}}{z-z_{prp}}$$</span>
<span class="math-container">$$ y_p=y'= y.\frac{z_{vp}-z_{prp}}{z-z_prp}+y_{prp}.\frac{z-z_{vp}}{z-z_{prp}}$$</span></p>

<p>and there is no projection transformation matrix  given.  </p>

<p>In the second text,  the  derivation is using  similar triangles:<br>
<a href="https://i.sstatic.net/SakPQ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/SakPQ.jpg" alt="image2"></a><br>
comparing the  similar triangles  we  get:
<span class="math-container">$$x_p=\frac{-x_c}{\frac{z_c}{d}}$$</span>
<span class="math-container">$$y_p=\frac{y_c}{\frac{z_c}{d}}$$</span></p>

<p>and  the projection transformation for  homogeneous coordinates x,y,z is  given by:
<span class="math-container">$$
\begin{bmatrix}
-1&amp;&amp;0&amp;&amp;0&amp;&amp;0\\
0&amp;&amp;1&amp;&amp;0&amp;&amp;0\\
0&amp;&amp;0&amp;&amp;1&amp;&amp;0\\
0&amp;&amp;0&amp;&amp;\frac{1}{d}&amp;&amp;0
\end{bmatrix}
$$</span>    </p>

<p><strong>so,  my questions are:</strong></p>

<ul>
<li>How do I find the projection matrix of coordinates as found from 
derivation 1?</li>
<li>Both are given in the perspective projection area of
these different texts,  are both transformations the  same? If not, 
how  are  they different?</li>
</ul>

CC BY-SA 4.0
2018-11-13T21:38:48.163Z
I think that my answer to your [other question](https://computergraphics.stackexchange.com/questions/8255/finding-the-projection-matrix-for-one-point-perspective/) applies here as well.
vgs
<projections>
perspective projection transformation matrix
mathmaniage
# perspective projection transformation matrix

(Asked by: username_0 on 2018-11-12)

In one text, the derivation for perspective projection goes like this: [![image1](https://i.sstatic.net/ZHCE0.jpg)](https://i.sstatic.net/ZHCE0.jpg)

If $x',y',z'$ represent any point along the projection line,and $x\_{prp},y\_{prp},z\_{prp}$ are the projection reference point, then:

$$x'=x-(x-x\_{prp})u$$  
$$y'=y-(y-y\_{prp})u$$
$$z'=z-(z-z\_{prp})u$$
where $0\le u \le 1$

Now, finding the value of u from the third equation above and replacing in the first and second equations, we get at $z\_vp$:

$$ x\_p=x'= x.\frac{z\_{vp}-z\_{prp}}{z-z\_prp}+x\_{prp}.\frac{z-z\_{vp}}{z-z\_{prp}}$$
$$ y\_p=y'= y.\frac{z\_{vp}-z\_{prp}}{z-z\_prp}+y\_{prp}.\frac{z-z\_{vp}}{z-z\_{prp}}$$

and there is no projection transformation matrix given.

In the second text, the derivation is using similar triangles:  
[![image2](https://i.sstatic.net/SakPQ.jpg)](https://i.sstatic.net/SakPQ.jpg)  
comparing the similar triangles we get:
$$x\_p=\frac{-x\_c}{\frac{z\_c}{d}}$$
$$y\_p=\frac{y\_c}{\frac{z\_c}{d}}$$

and the projection transformation for homogeneous coordinates x,y,z is given by:
$$
\begin{bmatrix}
-1&&0&&0&&0\\
0&&1&&0&&0\\
0&&0&&1&&0\\
0&&0&&\frac{1}{d}&&0
\end{bmatrix}
$$

**so, my questions are:**

* How do I find the projection matrix of coordinates as found from
  derivation 1?
* Both are given in the perspective projection area of
  these different texts, are both transformations the same? If not,
  how are they different?

**Tags:** projections

> **Comments:**
> **username_1**: I think that my answer to your [other question](https://computergraphics.stackexchange.com/questions/8255/finding-the-projection-matrix-for-one-point-perspective/) applies here as well.  

---

## 1 answers

### Answer by username_1 on 2018-11-14. Score: 0 | Accepted answer

Given your equations (which i just assume are correct):
$$
\begin{align}
x\_p &= x \frac{z\_{vp}-z\_{prp}}{z-z\_{prp}}+x\_{prp} \frac{z-z\_{vp}}{z-z\_{prp}}\\
y\_p &= y \frac{z\_{vp}-z\_{prp}}{z-z\_{prp}}+y\_{prp} \frac{z-z\_{vp}}{z-z\_{prp}}
\end{align},
$$

if we take $(x\_{prp}, y\_{prp}, z\_{prp}) = (0, 0, 0)$, then we have

$$
\begin{align}
x\_p &= x\frac{z\_{vp}}{z}\\
y\_p &= y\frac{z\_{vp}}{z}
\end{align}
$$

Assuming the projection plane is at distance $d$ from the origin, and, by your drawing, that the projection plane is on the negative side of the Z axis, we have $z\_{vp} = -d$, which leads to

$$
\begin{align}
x\_p &= - x\frac{d}{z}\\
y\_p &= - y\frac{d}{z}
\end{align}
$$

Now we can follow the same reasoning (homogeneous coordinates) as [in my answer to your other question](https://computergraphics.stackexchange.com/questions/8255/finding-the-projection-matrix-for-one-point-perspective) (using column notation) to write

$$
\begin{align}
\begin{bmatrix}
x\\y\\z\\ \frac{-z}{d}
\end{bmatrix}
=
\begin{bmatrix}
1&0&0&0\\
0&1&0&0\\
0&0&1&0\\
0&0&\frac{-1}{d}&0
\end{bmatrix}
\begin{bmatrix}
x\\y\\z\\1
\end{bmatrix}
\end{align}
$$

which after the division by the last coordinate will give the projected point. Notice that because we are writing it in column notation, the perspective matrix is the transpose of the matrix in your [other question](https://computergraphics.stackexchange.com/questions/8255/finding-the-projection-matrix-for-one-point-perspective). Also, the negative sign is because the camera reference frame is a right-handed one.

As for the second textbook that you are reading, I cannot understand why you would have a negative sign only in the x axis without knowing more about the camera reference frame. By the diagram you posted, there should not be a negative sign.

> **Comments:**
> **username_0**: thank you for answering here as well, one user pointed out that the negative sign  was due to reflection on the yz plane to correct  the reference frame.... so the x coord was reflected was what he said.  
> **username_0**: if you have some time, could you please take a look at [this question of mine](https://computergraphics.stackexchange.com/questions/8262/preserving-z-values-during-projection) , I  can't  really seem to understand the given explanation.  
> **username_1**: Sorry for taking me so long to answer your comment. Another user has already answered your question, and it seems to be correct. If you just apply the perspective matrix as shown above, every z-value will map to d, losing the information about object ordering, which is needed for the Z-buffer algorithm to correctly render the scene. So, the original range of Z values is usually mapped to another range, such that after perspective projection, Z is mapped to normalized device coordinates, as expected by your graphics API of choice.  

---

