4.3.2 Perspective Projection

This is a more realistic projection as approximately used by cameras. Again we project to some plane, but this time with rays starting from some `location' (on the side of the plane opposite to the objects). The simplest situation is, when the location is at the origin, and the plane we project to is given by $ z=1$. The projection is then given by

$\displaystyle \langle v_1,v_2,v_3\rangle\mapsto \langle \frac{v_1}{v_3},\frac{v_2}{v_3},1\rangle
$

Unfortunately this is not longer a linear mapping (because of the $ 1/v_3$ term). In order to describe this again by a matrix we consider homogeneous coordinates, i.e. we extend the coordinates of points in $ \protect\mathbb{R}^3$ by appending a forth coordinate 1. And on the other hand we associate to each vector in $ \protect\mathbb{R}^4$ (with non-vanishing last coordinate) that point in $ \protect\mathbb{R}^3$, which we get by dividing the first 3 coordinates by the forth. More generally we identify two vectors ($ v,v'\ne 0$) in $ \protect\mathbb{R}^4$ if they are collinear, i.e. there exists a number $ \lambda \in\protect\mathbb{R}$ such that $ v'=\lambda \,v$. Up to this identification we can write this projection as

$\displaystyle \begin{pmatrix}
v_1 \\ v_2 \\ v_3 \\ 1
\end{pmatrix}\mapsto
\beg...
...0 & 0 & 0 & 0
\end{pmatrix}\begin{pmatrix}
v_1 \\ v_2 \\ v_3 \\ 1
\end{pmatrix}$

Similar formulas hold for arbitrary projection planes (and location).

The projection onto the plane $ z=d$ is given by:

$\displaystyle \begin{pmatrix}
d & 0 & 0 & 0 \\
0 & d & 0 & 0 \\
0 & 0 & d & 0 \\
0 & 0 & 1 & 0
\end{pmatrix}$

or, equivalently, by

$\displaystyle \begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 1/d & 0
\end{pmatrix}$

If we translate 0 and the plane to $ \langle 0,0,-d\rangle$ the projection becomes

$\displaystyle v$ $\displaystyle \mapsto v+d*z\mapsto \left\langle \frac{d\,v_1}{v_3+d},\frac{d\,v...
... \mapsto \left\langle \frac{d\,v_1}{v_3+d},\frac{d\, v_2}{v_3+d},0\right\rangle$    
  $\displaystyle = \left\langle \frac{v_1}{v_3/d+1},\frac{v_2}{v_3/d+1},0\right\rangle$    

For $ d\to{\infty}$ this is the orthographic projection from above.

Let the projection plane be given in normal form by $ F:=\{v:\langle v\vert n\rangle =d\}$, where $ n$ is a unit normal vector to the plane and $ d$ is the signed distance to 0, i.e. is positive if $ n$ points from 0 to the plane and negative otherwise. The corresponding perspective projection is given by $ v\mapsto v'$, where $ v'=\lambda \,v\in F$, i.e. $ \lambda \,\langle v\vert n\rangle =d$, thus

$\displaystyle v\mapsto v':= \frac{d}{\langle v\vert n\rangle} v.
$

In homogeneous coordinates this can be described by the matrix

$\displaystyle \begin{pmatrix}
d & 0 & 0 & 0 \\
0 & d & 0 & 0 \\
0 & 0 & d & 0 \\
n_1 & n_2 & n_3 & 0
\end{pmatrix}$

Since we have not infinite large images but some finite rectangle we have to clip the image, and hence we may clip the objects to some prism or pyramid.

Figure: Pov-Ray's camera definition
Image /home/andreas/tex/Books/computer-graphics/img//perspcam.gif

The syntax in Pov-Ray for the general camera definition is as follows:

	CAMERA:
	    camera{ [CAMERA_ITEMS...] }
	CAMERA_ITEM:
	    CAMERA_TYPE | CAMERA_VECTOR | CAMERA_MODIFIER |
	    CAMERA_IDENTIFIER
	CAMERA_TYPE:
	    perspective | orthographic | fisheye | ultra_wide_angle |
	    omnimax | panoramic | cylinder CylinderType | spherical
	CAMERA_VECTOR:
	    location <Location> | right <Right> | up <Up> | 
	    direction <Direction> | sky <Sky>
	CAMERA_MODIFIER:
	    angle HORIZONTAL [VERTICAL] | look_at <Look_At> |
	    blur_samples Num_of_Samples | aperture Size |
	    focal_point <Point> | confidence Blur_Confidence |
	    variance Blur_Variance | NORMAL | TRANSFORMATION

	Camera default values:

	DEFAULT CAMERA:
	  camera {
	    perspective
	    location <0,0,0>
	    direction <0,0,1>
	    right 1.33*x
	    up y
	    sky <0,1,0>
	  }

	CAMERA TYPE: perspective
	angle      : ~67.380 ( direction_length=0.5*
	                       right_length/tan(angle/2) )
	confidence : 0.9 (90%
	direction  : <0,0,1>
	focal_point: <0,0,0>
	location   : <0,0,0>
	look_at    : z
	right      : 1.33*x
	sky        : <0,1,0>
	up         : y
	variance   : 1/128
From [pov:180.html#target_713]

Note also the following:


	6.4.1  Placing the Camera 
	  6.4.1.1    Location and Look_At
		6.4.1.2    The Sky Vector
		6.4.1.3    Angles
		6.4.1.4    The Direction Vector
		6.4.1.5    Up and Right Vectors
		  6.4.1.5.1    Aspect Ratio
			6.4.1.5.2    Handedness
		6.4.1.6    Transforming the Camera
	6.4.2  Types of Projection 
	6.4.3  Focal Blur 
	6.4.4  Camera Ray Perturbation 
	6.4.5  Camera Identifiers

Andreas Kriegl 2003-07-23