THIS DOCUMENT HAS BEEN CERTIFIED
MEANNESS RATING 6/10
 
 
 
 
 
 
 

NOTE : vectors are represented by capitals, scalars are represented by lower case. The x, y, and z components of a vector are denoted by '.x', '.y', and '.z' respectively. For example, the x component of the vector V would be represented by 'V.x'.
 
 
 

The Coordinate System and the Camera
    Below is a diagram of the coordinate system employed.

    The camera is always :
    -located at the origin
    -pointing in a positive z-direction
 
 
 
 

Projecting a 3D Point Onto the Screen
 

    Below is the BASIC formula for projecting the 3D point represented by the vector P, onto the screen, into the 2D vector S :
 

    There are a couple of problems with the above formula. Firstly, any point lying on the z-axis (x=0, y=0, z=?) will be projected onto (0,0) on the screen, - the top left corner. A point on the z-axis should be projected onto the centre of the screen, so if w and h are the screen's width and height respectively, so the coordinated should be (w/2,h/2), so this makes the formula :
 


 

    Secondly, the field of view is too large. In the above formula, the field of view will also depend on the screen resolution used, - the large greater the resolution, the larger the field of view. There is no way of controlling the field of view. Below is a formula for implementing variable horizontal field of view :
 

    'f' is a scalar, which will alter the horizontal field of view. To calculate 'f', given the horizontal field of view 'a' degrees, use the formula

Below are the formulae required to calculate 'f' and 'g' using 'a' and 'b' as the horizontal and vertical fields of view respectively, and then project point P onto the screen, with the result being the vector S.


 
 

Reverse Perspective Projection

    In applications such as raytracing, it may be necessary to produce a vector of a ray for a pixel. To do this, we simple reverse the formula. Firstly, the formule for the x-coordinate will be reversed. Note that the 'f' and 'g' from normal prespective projection described above can be used here. We know S, (the screen coordinates) and we want to find P, however, we must set a value for P.z. We will set it to 1, to keep things simple. Here is the process by which the perspective projection formula can be rearranged :

This means that (since the same rules apply to x and y) :

It is likely that the vector P would be most useful if it were normalized. To do this divide each of the x, y, and z components of the vector by the vector's length.
 
 
 

        Email suggestions, comments, death threats, questions, etc to :

                mrmeanie@easynet.co.uk
 
 

 Return to 3D Algorithms Page