We are looking for a $4\times4$ transformation matrix for homogeneous coordinates which will map the viewing frustum, a truncated pyramid as described earlier, onto the standard cube in homogeneous coordinates $-1\le x'/w'\le +1, -1\le y'/w'\le +1, -1\le z'/w'\le +1$:

  • First, we consider the case of symmetrical perspective projection with $\theta_y = 90^\circ$ and r=1 (square window). The central projection (with center in the origin) of the viewing frustum on the plane z=-1 is then the square [-1,+1]2.

    This central projection is described by the following transformation matrix:

     \begin{displaymath}\mathbf{P} =
1 & 0 & 0 & 0 \\
0 & 1 & 0 &...
\begin{pmatrix}x \\ y \\ z \\ -z \end{pmatrix}\end{displaymath} (11)

    Indeed: the resulting point has affine coordinates $(\frac{x}{-z}, \frac{y}{-z}, -1)$, which is precisely the intersection of the line from the origin to the point (x,y,z) with the z=-1 plane.

    This transformation suffices when we are not interested in z'. This is the case when no visible face determination is needed.

  • The projection matrix P in (15) leaves the z-coordinate unchanged. After division by w'=-z we always obtain z''=-1. Due to the perspective division it is no longer possible to determine z'' as a linear function of z, as was the case in the third step of §5.1. However, it is still possible to construct the projection matrix such that $z'' = \frac {z'}{w'}$ is a monotonically increasing (non-linear) function of the depth -z of the point, in the range [-1,+1]. Fortunately, this is all we need for visible surface determination.

    z' is determined by the coefficients in the third row of P. We will now determine those coefficients so as to obtain the desired effect. The new matrix is designated by Q. There is no need for z' to depend on x or y. Therefore, the first two coefficients can have value 0. We will call the last two coefficients a and b. An arbitrary point (x,y,z,1), in eye coordinates, is then transformed into:

    \begin{displaymath}\begin{pmatrix}x' \\ y' \\ z' \\ w' \end{pmatrix} =
\frac{z'}{w'} = \frac{a\cdot z + b}{-z}.
\end{displaymath} (12)

    We want to map $z_{\text {front}}$ onto -1 and $z_{\text{back}}$ onto +1:
    $\displaystyle \frac{a\cdot z_{\text{front}}+ b}{-z_{\text{front}}}$ = -1  
    $\displaystyle \frac{a\cdot z_{\text{back}}+ b}{-z_{\text{back}}}$ = +1 (13)

    These two relations lead to a set of two equations with two unknowns a and b. Their solution is:
    a = $\displaystyle \frac{z_{\text{front}}+z_{\text{back}}}{z_{\text{front}}-z_{\text{back}}}$  
    b = $\displaystyle \frac{-2\cdot z_{\text{front}}\cdot z_{\text{back}}}{z_{\text{front}}-z_{\text{back}}}.$ (14)

    Figure 5 shows how $\frac{z'}{w'}$ varies as a monotonically increasing, but non-linear function of z.

    Figure: The graphs below show how the normalized device z-coordinate $z'' = \frac {z'}{w'}$ (vertical axis) varies as a non-linear, monotonically increasing function of -z, the distance from a point to the eye XY-plane (horizontal axis) when using the matrix Q. In the three cases shown, $z_{\text {back}}=-100$. The value of $z_{\text {front}}$ is -10, -1 and -0.1 in the left, middle and right graph respectively. Notice that the closer $z_{\text {front}}$ comes to the eyepoint z=0, the less uniformly the Z-buffer is filled: a larger range of eye z-values will be mapped onto a smaller range of Z-buffer values (values close to $\frac {z'}{w'} = +1$). When the Z-buffer has only a limited resolution (e.g. 16 bits), hidden face elimination with the Z-buffer algorithm will not work well for points in the far distance: points with large depth differences could then be represented by the same discrete Z-buffer value. This is why in practice, one should take care to position the front clipping plane $z=z_{\text {front}}$ as far as possible from the eye point.

  • The matrix Q suffices for symmetrical perspective projection with $\theta_y = 90^\circ$ and r=1. The general case should first be reduced to this special case. This step corresponds to the second step in §5.1

    • A symmetrical perspective projection with $\theta_y \ne 90^\circ$ and/or $r \ne 1$ is reduced to the previous case by simply scaling x and yby $\mathbf{M_s}(\vec{S})$ (2). The scaling factors are $\vec{S} = (\frac{2}{W}, \frac{2}{H}, 1)$ with W and H given in (11) (check this yourself!). The complete projection matrix for symmetrical perspective is then:
       \begin{displaymath}\mathbf{Q}\cdot\mathbf{M_s}(\vec{S}) =
...xt{front}}-z_{\text{back}}} \\
0 & 0 & -1 & 0
\end{displaymath} (15)

    • For asymmetrical perspective projection the frustum is first transformed such that its axis coincides with the negative Z-axis. This requires a translation perpendicular to the Z-axis, over a distance proportional to -z (see figure 6). The top of the frustum lies in the origin and should remain there. The center $(\frac{x_{\text{right}}+x_{\text{left}}}{2}, \frac{y_{\text{top}}+y_{\text{bottom}}}{2}, z_{\text{front}})$of the front plane of the frustum should be mapped onto $(0,0,z_{\text{front}})$. This is called a shearing-transformation. The required transformation matrix is (check for yourself!):
      \begin{displaymath}\mathbf{S} =
1 & 0 & \frac{x_{\text{right}}+...
...om}}}{-2z_{\text{front}}} \cdot z \\
z \\
\end{displaymath} (16)

      The projection on the z=-1 plane is now symmetrical about the Z-axis, but its dimensions are not yet correct. The shearing transformation is therefore followed by a scaling transformation $\mathbf{M_s}(\vec{S})$(2) with
      \begin{displaymath}\vec{S} = \left(\frac{-2z_{\text{front}}}{x_{\text{right}}-x_...
...z_{\text{front}}}{y_{\text{top}}-y_{\text{bottom}}}, 1\right).
\end{displaymath} (17)

      $\mathbf{M_s}(\vec{S})$ reduces the dimensions $\frac{x_{\text{right}}-x_{\text{left}}}{-z_{\text{front}}}$ and $\frac{y_{\text{top}}-y_{\text{bottom}}}{-z_{\text{front}}}$ of the projection in the z=-1 plane to 2 units in the x and the y direction. The complete asymmetrical perspective projection matrix is:
       \begin{displaymath}\mathbf{Q}\cdot\mathbf{M_s}(\vec{S})\cdot\mathbf{S} =
...xt{front}}-z_{\text{back}}} \\
0 & 0 & -1 & 0
\end{displaymath} (18)

      You should verify that this transformation, followed by a division by w', yields the same x'' and y'' as in §5.1. The z'' however is different, but still adequate for hidden face elimination.

Figure 6: An asymmetrical perspective projection reduces to a symmetrical perspective projection by a shearing transformation: a translation perpendicular to the Z-axis over a distance proportional to -z. This transformation maps the frustum axis on the negative Z-axis.

출처 : http://www.cs.kuleuven.ac.be/cwis/research/graphics/INFOTEC/viewing-in-3d/node8.html

혹시모르는 페이지 저장.. 

'알고리즘 > 이미지 처리' 카테고리의 다른 글

역행렬 구하기  (0) 2008.03.05
이중선형 필터링  (0) 2008.03.05
Perspective projection matrix  (0) 2008.03.05
다각형을 가져오기 위한 노력...  (0) 2008.03.04
ImageWarping Processing  (0) 2008.02.26
PNG 분석자료들  (0) 2008.02.24

+ Recent posts