This node is about perspective projection in computer graphics. It describes how perspective can be introduced into a system of affine transformations. The way this is achieved is to introduce a perspective parameter into the transformation matrix. This parameter results in the coodinate system moving from Euclidean space into perspective sub-space. This means that once you have calculated the position in the sub-space you then have to transform it back into Euclidean space before showing it to the user.

There are two ways to look at perspective projection. Both are essentially the same it is just a question of which one you feel more comfortable with. They are both based on the idea of a point of convergence of perspective lines that come from the object being projected. The difference strems from where the virtual 'screen' onto which the image is projected actually is: it can either be positioned in front of or behind the vanishing point as the following diagram shows.



                      ^
                      |
                      |                         __/
                      |                      __/  ^
                      |                   __/     |
                      |                __/        |
                      |             __/           |
                      |          __/              | Object
                      |       __/ ^               |
                      |    __/    | Front Proj    |
                      | __/       |   Object      |
    __________________|/__________|_______________|__
         |        __/ |o            
         |     __/    | Vanishing Point
         |  __/       |
         v_/          | 
      __/             |

   Back Projection
       Object

I personally prefer the back projection model not least because it makes for less cuttered diagrams. The maths is, however, identical. Now for the maths part, you can skip this part if you like and go straight to the bit with the matices if that's all you're interested in. The maths is derived from the following diagram which many of you will recognise from basic light physics as the diagram of the way a lens works which, of course, is what it is.






                         ^
                         |
                         |___________________________i
                       _/|i''                   __/  ^
                     _/ /|                   __/     |
                   _/  / |                __/        |
                 _/   /  |             __/           |
               _/    /   |          __/              |
             _/    _/    |       __/                 |
           _/     /      |    __/                    |
         _/     _/       | __/                       |
       _/______/_________|/__________________________|__
        |d'  _/f'    __/ |o        f        2f       d
        |   /     __/    |         
        | _/   __/       | 
        |/  __/          | 
        v__/             |
        i'               |

Observe that odi and od'i' are similar triangles as are f'oi' and f'd'i'. This means that:

i = -i' = i'  =>  d' =  di'
d   -d'   d'            i

and

i'' =  -i'
f'    d'-f

Substituting i = i'' and d' = di' gives:
                               i

i =    -i'   
f'  (di'/i)-f

Substitute -f' = f and solve for i':

i' =   i  
     1-d/f


This leads to the following transfomation (in 2D)


  |1   0  0| |i|   |  i  |
  |0   1  0| |d| = |  d  |
  |0 -1/f 1| |1|   |1-d/f|

Which gives the position of the 2D point in perspective sub-space. To transform into Euclidean space simply perform homogeneous division:

  |  i  |
  |1-d/f|
  |  d  |
  |1-d/f|
  |  1  |

In 3D it is very much the same story. The only difference is that when you are applying perspective you almost always want to do it from the camera just before you display it so calculating the z coordinate of the result is pretty much pointless. This assumes the camera is the origin and the projection plane is parallel to the x-y plane of the camera i.e. you are looking along the camera's z axis.

  |1 0   0  0| |x|   |  x  |
  |0 1   0  0| |y| = |  y  |
  |0 0   1  0| |z|   |  z  |
  |0 0 -1/f 1| |1|   |1-z/f|

Leads to
 
 |  x  |
 |1-z/f|
 |  y  |
 |1-z/f|
 |  z  | <-- Pointless!
 |1-z/f|
 |  1  |

Sources:
Burger and Gilles, "Interactive Computer Graphics", Addison Wesley, 1989, ISBN: 0-201-17439-1
Foley, van Dam, Feiner and Hughes, "Computer Graphics Principles and Practice", Addison Wesley, 1997, ISBN: 0-201-84840-6
J.A.D.W. Anderson, "Computer Graphics 2001" Lecture Notes, Reading University.

Node your Revision!

Log in or register to write something here or to contact authors.