3D Projection - Perspective Projection

Perspective Projection

See also: Transformation matrix See also: Camera matrix

When the human eye views a scene, objects in the distance appear smaller than objects close by - this is known as perspective. While orthographic projection ignores this effect to allow accurate measurements, perspective definition shows distant objects as smaller to provide additional realism.

The perspective projection requires a more involved definition as compared to orthographic projections. A conceptual aid to understanding the mechanics of this projection is to imagine the 2D projection as though the object(s) are being viewed through a camera viewfinder. The camera's position, orientation, and field of view control the behavior of the projection transformation. The following variables are defined to describe this transformation:

  • - the 3D position of a point A that is to be projected.
  • - the 3D position of a point C representing the camera.
  • - The orientation of the camera (represented, for instance, by Tait–Bryan angles).
  • - the viewer's position relative to the display surface.

Which results in:

  • - the 2D projection of .

When and the 3D vector is projected to the 2D vector .

Otherwise, to compute we first define a vector as the position of point A with respect to a coordinate system defined by the camera, with origin in C and rotated by with respect to the initial coordinate system. This is achieved by subtracting from and then applying a rotation by to the result. This transformation is often called a camera transform, and can be expressed as follows, expressing the rotation in terms of rotations about the x, y, and z axes (these calculations assume that the axes are ordered as a left-handed system of axes):


\begin{bmatrix} \mathbf{d}_x \\ \mathbf{d}_y \\ \mathbf{d}_z \\
\end{bmatrix}=\begin{bmatrix} 1 & 0 & 0 \\ 0 & {\cos \mathbf{\theta}_x } & { - \sin \mathbf{\theta}_x } \\ 0 & { \sin \mathbf{\theta}_x } & { \cos \mathbf{\theta}_x } \\
\end{bmatrix}\begin{bmatrix} { \cos \mathbf{\theta}_y } & 0 & { \sin \mathbf{\theta}_y } \\ 0 & 1 & 0 \\ { - \sin \mathbf{\theta}_y } & 0 & { \cos \mathbf{\theta}_y } \\
\end{bmatrix}\begin{bmatrix} { \cos \mathbf{\theta}_z } & { - \sin \mathbf{\theta}_z } & 0 \\ { \sin \mathbf{\theta}_z } & { \cos \mathbf{\theta}_z } & 0 \\ 0 & 0 & 1 \\
\end{bmatrix}\left( {\begin{bmatrix} \mathbf{a}_x \\ \mathbf{a}_y \\ \mathbf{a}_z \\
\end{bmatrix} - \begin{bmatrix} \mathbf{c}_x \\ \mathbf{c}_y \\ \mathbf{c}_z \\
\end{bmatrix}} \right)

This representation corresponds to rotating by three Euler angles (more properly, Tait–Bryan angles), using the xyz convention, which can be interpreted either as "rotate about the extrinsic axes (axes of the scene) in the order z, y, x (reading right-to-left)" or "rotate about the intrinsic axes (axes of the camera) in the order x, y, z (reading left-to-right)". Note that if the camera is not rotated, then the matrices drop out (as identities), and this reduces to simply a shift:

Alternatively, without using matrices, (note that the signs of angles are inconsistent with matrix form):


\begin{array}{lcl}
	d_x &= &\cos \theta_y\cdot(\sin \theta_z\cdot(a_y-c_y)+\cos \theta_z\cdot(a_x-c_x))-\sin \theta_y\cdot(a_z-c_z) \\
	d_y &= &\sin \theta_x\cdot(\cos \theta_y\cdot(a_z-c_z)+\sin \theta_y\cdot(\sin \theta_z\cdot(a_y-c_y)+\cos \theta_z\cdot(a_x-c_x)))+\cos \theta_x\cdot(\cos \theta_z\cdot(a_y-c_y)-\sin \theta_z\cdot(a_x-c_x)) \\
	d_z &= &\cos \theta_x\cdot(\cos \theta_y\cdot(a_z-c_z)+\sin \theta_y\cdot(\sin \theta_z\cdot(a_y-c_y)+\cos \theta_z\cdot(a_x-c_x)))-\sin \theta_x\cdot(\cos \theta_z\cdot(a_y-c_y)-\sin \theta_z\cdot(a_x-c_x)) \\
\end{array}

This transformed point can then be projected onto the 2D plane using the formula (here, x/y is used as the projection plane; literature also may use x/z):


\begin{array}{lcl} \mathbf{b}_x &= &(\mathbf{d}_x - \mathbf{e}_x) (\mathbf{e}_z / \mathbf{d}_z) \\ \mathbf{b}_y &= &(\mathbf{d}_y - \mathbf{e}_y) (\mathbf{e}_z / \mathbf{d}_z) \\
\end{array}.

Or, in matrix form using homogeneous coordinates, the system


\begin{bmatrix} \mathbf{f}_x \\ \mathbf{f}_y \\ \mathbf{f}_z \\ \mathbf{f}_w \\
\end{bmatrix}=\begin{bmatrix} 1 & 0 & 0 & -\mathbf{e}_x \\ 0 & 1 & 0 & -\mathbf{e}_y \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 1/\mathbf{e}_z & 0 \\
\end{bmatrix}\begin{bmatrix} \mathbf{d}_x \\ \mathbf{d}_y \\ \mathbf{d}_z \\ 1 \\
\end{bmatrix}

in conjunction with an argument using similar triangles, leads to division by the homogeneous coordinate, giving


\begin{array}{lcl} \mathbf{b}_x &= &\mathbf{f}_x / \mathbf{f}_w \\ \mathbf{b}_y &= &\mathbf{f}_y / \mathbf{f}_w \\
\end{array}.

The distance of the viewer from the display surface, directly relates to the field of view, where is the viewed angle. (Note: This assumes that you map the points (-1,-1) and (1,1) to the corners of your viewing surface)

The above equations can also be rewritten as:


\begin{array}{lcl} \mathbf{b}_x= (\mathbf{d}_x \mathbf{s}_x ) / (\mathbf{d}_z \mathbf{r}_x) \mathbf{r}_z\\ \mathbf{b}_y= (\mathbf{d}_y \mathbf{s}_y ) / (\mathbf{d}_z \mathbf{r}_y) \mathbf{r}_z\\
\end{array}.

In which is the display size, is the recording surface size (CCD or film), is the distance from the recording surface to the entrance pupil (camera center), and is the distance, from the 3D point being projected, to the entrance pupil.

Subsequent clipping and scaling operations may be necessary to map the 2D plane onto any particular display media.

Read more about this topic:  3D Projection

Famous quotes containing the words perspective and/or projection:

    All things being equal, I would choose a woman over a man in order to even the balance of power, to insinuate a different perspective into the process, to give young women something to shoot for and someone to look up to. But all things are rarely equal.
    Anna Quindlen (b. 1952)

    In the case of our main stock of well-worn predicates, I submit that the judgment of projectibility has derived from the habitual projection, rather than the habitual projection from the judgment of projectibility. The reason why only the right predicates happen so luckily to have become well entrenched is just that the well entrenched predicates have thereby become the right ones.
    Nelson Goodman (b. 1906)