0
$\begingroup$

I know that ( Reference )in transformation source and destination has same coordinates dimensions. But in projection destination coordinate system has fewer dimensions than the source coordinate system.

And in perspective projection the world co-ordinate $(x_w, y_w, z_w)$ has transformed to $(x_p, y_p, z_p)$ in projection plane. Since dimensions has remains same here, so it should be perspective transformation. My question is why we said perspective projection instead of perspective transformation?

$\endgroup$
16
  • 1
    $\begingroup$ Your question seems to answer itself, the projection plane is 2D the world is 3D. $\endgroup$
    – pmw1234
    Nov 1, 2021 at 12:05
  • 2
    $\begingroup$ Do explain how you get $(x_p, y_p, z_p)$ mathematically, which will explain your confusion. $\endgroup$
    – lightxbulb
    Nov 1, 2021 at 12:12
  • 2
    $\begingroup$ I know what perspective projection is, I am not convinced you do however, which is why I am asking you to write the math. If I see that your math is wrong then I can correct that. If I see that it is correct then I can focus on explaining how you get a 2D subspace. $\endgroup$
    – lightxbulb
    Nov 1, 2021 at 12:16
  • 2
    $\begingroup$ "I understand the math of perspective projection." - then please write it down in your question/the comments. As it is, it's unclear whether $(x_p, y_p, z_p)$ is in clip space, ndc, or some other space (I assume it's ndc since you've dropped $w$). $\endgroup$
    – lightxbulb
    Nov 1, 2021 at 12:23
  • 2
    $\begingroup$ @User4567: Basically, everything being said here seems to be further retreads of stuff also said elsewhere, just using different words. $\endgroup$ Nov 1, 2021 at 17:06

1 Answer 1

2
$\begingroup$

It seem like there's some confusion about how perspective projection works in the first place, so I will try to clarify this point.

Let $p_w = (p_{w,1}, p_{w,2}, p_{w,3})$ be the world-space coordinates of some point $p$. By world space I mean that the coordinates are defined with respect to the standard coordinate system in $\mathbb{R}^3$ with origin $O=(0,0,0)$ and basis $e_1=(1,0,0), e_2=(0,1,0), e_3=(0,0,1)$. Introduce a notion of camera which for the current purpose would be defined through an origin $c_w = (c_{w,1}, c_{w,2}, c_{w,3})$ and orthonormal basis vectors: $t_w = (t_{w,1}, t_{w,2}, t_{w,3})$, $n_w = (n_{w,1}, n_{w,2}, n_{w,3})$, $b_w = (b_{w,1}, b_{w,2}, b_{w,3})$. Then the point $p_w$ can be expressed also through its coordinates $p_v$ in the camera's coordinate system: $p_w = c_w + p_{v,1}t_w + p_{v,2}n_w + p_{v,3}b_w$, or equivalently in matrix notation:

$$p_w = c_w+M p_v, \, M = \begin{pmatrix} t_{w,1} & n_{w,1} & b_{w,1} \\ t_{w,2} & n_{w,2} & b_{w,2} \\ t_{w,3} & n_{w,3} & b_{w,3} \end{pmatrix}.$$

To find $p_v$ we compute $p_v = M^{-1}(p_w-c_w) = M^T(p_w-c_w)$. Now assume that we want the camera's projection plane to be at $z_{v}=1$ in the camera's coordinate system (i.e. it's perpendicular to the $b$ vector and it's at an offset of $1$ from $c$ along it). We can find the perspective projection $p_{\pi}$ onto that plane using: $p_{\pi} = \left(\frac{p_{v,1}}{p_{v,3}}, \frac{p_{v,2}}{p_{v,3}}\right)$. As you can see the projected point is two-dimensional, its 3-dimensional analogue (as a 3D point on the film) in the camera's coordinate system is $\left(\frac{p_{v,1}}{p_{v,3}}, \frac{p_{v,2}}{p_{v,3}}, 1\right)$.

In computer graphics, we typically need some depth information while drawing fragments/pixels to figure out which surfaces are occluded and which aren't (see Z-buffer). For that purpose it is useful to also keep information about the "depth" of $p_v$ before it gets projected, then the third coordinate is kept in the form $a + \frac{b}{p_{v,3}}$ where $a$ and $b$ are constants determined by the near and far plane values. Thus in ndc coordinates you typically have the triple $\left(\frac{p_{v,1}}{p_{v,3}}, \frac{p_{v,2}}{p_{v,3}}, a + \frac{b}{p_{v,3}}\right)$ (sometimes a division by the negative of $p_{v,3}$ is employed). Using the third coordinate one can figure out whether a specific point $p$ is "behind" another point $q$: $p_{v,3} > q_{v,3}$.

Often people want to control the size of their imaginary camera film, and the near and far plane values. To achieve this typically a projection matrix is applied to $p_v$ before the division (yielding $p$ in clip space). Note that even though it's termed a projection matrix, it doesn't really project anything, as the projection occurs through the division.

An orthographic projection on the other hand is achieved by just dropping the last coordinate of $p_v$: $(p_{v,1}, p_{v,2})$.

Regarding implementation details in various APIs and some more information I would suggest reading: http://www.songho.ca/opengl/gl_projectionmatrix.html

http://www.songho.ca/opengl/gl_transform.html

https://learnopengl.com/Getting-started/Coordinate-Systems

https://learnopengl.com/Getting-started/Transformations

I should probably also touch upon how this is related to vanishing points. First to disambiguate from the pinhole/perspective projection point of the camera $c$: all points lying on the same line passing through $c_w$ (the origin/pinhole of the camera) and $p_{w}$ get projected to the same point $p_{\pi}$. Note that $c_w$ is not a vanishing point. Now consider parallel lines in 3D space. A line can be defined parametrically as $l(\alpha) = f + \alpha d, \alpha \in \mathbb{R}$, where $f$ is some point on the line and $d$ is its direction. Two lines $l(\alpha) = f+\alpha d,\, k(\beta) = g+\beta h$ are parallel if $d \parallel h$ ($\exists \gamma\ne 0: d=\gamma h$). Now given two arbitrary parallel lines in the coordinate system of the camera: $l_{v}(\alpha) = f_v + \alpha d_v, \, k(\beta) = g_v + \beta h_v$ their projections intersect on the projective plane at $\left( \frac{d_{v,1}}{d_{v,3}}, \frac{d_{v,1}}{d_{v,3}} \right) = \left( \frac{h_{v,1}}{h_{v,3}}, \frac{h_{v,1}}{h_{v,3}} \right)$ which one terms the vanishing point for all lines parallel to those. Artists sometimes draw those points to check the correctness of their perspective/construction :

https://i.stack.imgur.com/Nae7R.gif

The vanishing point doesn't exist only on the projection plane, but it also exists if we extend $\mathbb{R}^3$ with the points at infinity through homogeneous coordinates: $$(d_{v,1}, d_{v,2}, d_{v,3}, 0) = (\gamma h_{v,1}, \gamma h_{v,2}, \gamma h_{v,3}, 0) = (h_{v,1}, h_{v,2}, h_{v,3}, 0).$$

You can think of this point as one situated on a sphere at infinity - each unique direction gets its own point at infinity ($d$ and $h$ represent the same direction thus they get the same point at infinity). If you project this point onto the projection plane you get precisely the intersection point $\left( \frac{d_{v,1}}{d_{v,3}}, \frac{d_{v,1}}{d_{v,3}} \right) $ of the projection onto the projection plane of any lines parallel to $d$. There is a caveat for lines parallel to the projection plane (e.g. of the form $(d_{v,1}, d_{v,2}, 0)$): the intersection of their projections lies in $\mathbb{R}^2$ extended with homogeneous coordinates, namely: $(d_{v,1}, d_{v,2}, 0)$ (this means that their projections remain parallel in practice, and those are the only lines for which this holds).

$\endgroup$
10
  • 1
    $\begingroup$ @User4567 Refer to the links for images and additional intuition. Also try drawing it, it would likely help you with understanding it. $\endgroup$
    – lightxbulb
    Nov 2, 2021 at 19:03
  • 1
    $\begingroup$ @User4567: "please provide intuition not details wall" That's a catch-22. If we try to use analogies and use less detailed explanations, you claim not to understand something. If we provide all of the details, you claim that there's too much information. We can't play these kinds of games here. If you cannot explain, clearly what it is exactly that you don't understand, then we cannot help you. $\endgroup$ Nov 2, 2021 at 20:50
  • 2
    $\begingroup$ @NicolBolas I doubt that the actual issue is the details. At this point I am assuming that the OP lacks the mathematical background to understand the definition of projection. I have no solution to this however, as "intuitive" explanations have been presented in other posts but were supposedly unsatisfactory judging by the new threads in which the OP asks the same questions. Hopefully this turns out to be useful to someone else at least. $\endgroup$
    – lightxbulb
    Nov 2, 2021 at 21:14
  • 1
    $\begingroup$ OP does not know how to do linear algebra (told me so on GD.se). Bur really one shouldnt have to know how to do perspective transform to do understand motivation for linear algebra. But also apparently not vector fields either. $\endgroup$
    – joojaa
    Nov 3, 2021 at 20:09
  • 1
    $\begingroup$ @User4567 It would have helped if you mentioned not having studied linear algebra for several of your questions, then you could have gotten answers adequate to you. I would nevertheless suggest studying linear algebra (or a subset of it) if you plan to do anything related to programming graphics. I have found the learnopengl links I provided, in the post above, very accessible for beginners. $\endgroup$
    – lightxbulb
    Nov 4, 2021 at 8:24