# Projected points and screen coordinates

I'm trying to understand part of the contents of a slide, but I'm not really understanding. So, here's the interested part.

I've a few questions.

1. Are the projected points $q_1$ and $q_2$ the points with respectively the screen coordinates $(x_1, y_1)$ and $(x_2, y_2)$, i.e., $q_1 = \begin{pmatrix} x_1 \\ y_1\end{pmatrix}$ and $q_2 = \begin{pmatrix} x_2 \\ y_2\end{pmatrix}$?

2. Regarding how to obtain the projected points. What I understand from the slide is that the projected $3D$ points are obtained by dividing all coordinates of $p_1$ (e.g.) by its $z$ coordinate, i.e., $p_1^z$, so that we obtain $q_1 = \begin{pmatrix} \frac{p_1^x}{p_1^z} \\ \frac{p_1^y}{p_1^z} \\ \frac{p_1^z}{p_1^z} \end{pmatrix} = \begin{pmatrix} \frac{p_1^x}{p_1^z} \\ \frac{p_1^y}{p_1^z} \\ 1 \end{pmatrix}$. So, I guess, that at this point, we obtain the sccreen coordinates by ignoring the $1$ as the 3rd coordinate. Is that right?

• Can you link to the slides? It may help to answer the question better if we can put it in context. Nov 19, 2016 at 16:43
• Well, I'm not sure we can really answer the question as it's not clear from the slide how "screen coordinates" are defined relative to "projected points". There are various different coordinate systems that might be used; I don't know how the slide author has chosen to set things up. Nov 19, 2016 at 16:54

## 1 Answer

It's not 100% clear what the author means here, but I'll choose to interpret "screen coordinates" as "pixel coordinates". These would be related to the projected points by a 2D coordinate transformation.

You're correct that projection is done by dividing each component of a point by its $z$ component. (That's not quite true—actually, we usually use homogeneous coordinates, which have four components $xyzw$, and divide by the $w$ component, which has previously been set to eye-space $z$ by the projection matrix. This frees up the $z$ component of the vectors to be used for the z-buffer.) The projected points $q_i$ are then in "normalized device coordinates" or NDC space, which has a range of [−1, 1] on each axis.

To calculate the resulting pixel coordinates on the screen, we then need to perform a 2D scale-and-translate operation, to map the [−1, 1] range to the desired range of pixels. For example, if we want a 640×480 viewport, we could calculate $$x_i = 640 \cdot \frac{q^x_i + 1}{2} \\ y_i = 480 \cdot \frac{q^y_i + 1}{2}$$ You might also need to flip the $y$ axis in this transformation, for instance if the NDC space is Y-up but the pixel coordinates are Y-down.