Projections into Two-dimensional Space.

Copyright (c) Susan Laflin. August 1999.

We are dealing with objects defined in three-dimensional space, but all the graphics devices to which we have access are two-dimensional. This means that we require some way of representing(i.e drawing) the three-dimensional objects in two-dimensions in order to see the results. It is possible to calculate the intersection of any plane with the object and draw a sucession of slices, but it is usually easier to understand what is going on if we calculate the projection of the three dimensional object on to a given plane and then draw its projection.

There are two types of projection, parallel (usually orthographic) and perspective. We shall discuss both of these in the remainder of this chapter and also consider some other ways of giving the impression of a three-dimensional object in two-dimensions. All the diagrams in these chapters will use these methods. One of the most important is the removal of hidden lines or surfaces and this is discussed in another section

Parallel Projections.

The simplest example of an orthographic projection occurs when you project onto the plane z=0. You achieve this by ignoring the values of the z-coordinates and drawing the object in terms of its x and y coordinates only.

In general, an orthographic projection is carried out by drawing lines normal to the specified plane from each of the vertices of the object and the projected points are the intersections of these lines with the plane. Then the projected vertices are joined up to give the two-dimensional drawing. (It is also possible to project the drawing onto a plane which is not orthogonal (at right angles) to the direction of projection.)

Since calculating the intersections of general lines and planes is somewhat tedious, you may instead apply transformations to the objects so that the plane onto which you wish to project the drawing becomes the plane z=0. Then your final transformation into two-dimensions is obtained by discarding the z-coordinates. A simple example of an orthographic projection is shown in the figure below.

Orthographic Projection

There are several types of `axonometric' or parallel projections commonly in use. Let us look at some of them:

Trimetric. Here the coordinate axes remain orthogonal when projected.
Dimetric. Two of the three axes are equally foreshortened when projected.
Isometric. All three axes are equally foreshortened when projected.

The diagram below shows an example of a surface drawn using an isometric projection. It used a right-handed set of axes with the Ox axis to the right and inclined at 30degrees to the horizontal, the Oy axis to the left and inclined at the same angle, while the Oz axis is vertically upwards. The Oz axis has been drawn at the edges of the picture to avoid over-writing the graph.

Example of an Isometric Drawing of a Surface

Isometric Projection.

There are three stages in this projection.
	1).  Rotate through angle A about Oy axis.
	2).  Rotate through angle B about Ox axis.
	3).  Project onto plane z=0.
After this transformation, the unit vectors along the three axes 
must still be equal in length.
	1  0  0	0	1  0	0     0		cosA  0	sinA	0
T =	0  1  0	0	0 cosB	-sinB 0		0     1	  0	0
	0  0  0	0	0 sinB	cosB  0		-sinA 0	cosA	0
	0  0  0	1	0  0	0     1		0     0	  0	1

	cosA	 0	sinA	  0
T = 	sinBsinA cosB	-sinBcosA 0
	0	 0	0	  0
	0	 0	0	  1

Apply this transformation to the three unit vectors, namely xT=(1,0,0,1), yT=(0,1,0,1) and zT = (0,0,1,1) and you get the vectors (cosA,sinBsinA,0,1), (0,cosB,0,1) and (sinA,-sinBcosA,0,1). The magnitudes of the three vectors must be equal after the transformation, which gives us the following equations for the length L

	L =  SQRT( cos 2A + sin 2A.sin2B +1 ) 	= SQRT (cos2B + 1)
	    =  SQRT( sin2A + sin2B.cos2A + 1)

These equations can be re-arranged and solved for A and B. Eventually they give:

B = 35.26439 degrees, since sinB = 1/3
and A = 45 degrees, since cosA = 1/SQRT(2)

From these values of A and B we can calculate the transformation matrix

		0.7071 		0.0 		0.7071 		0.0 
	T = 	0.4082 		0.8166 		-0.4082 	0.0 
		0.0 		0.0 		0.0 		0.0 
		0.0 		0.0 		0.0 		1.0

which is the transformation matrix for an isometric projection.

This and other parallel projections are described in many texts on computer graphics, for example the second edition of Rogers and Adams.

Perspective Projections

Perspective projections are often preferred because they make the more distant objects appear smaller than those closer to the viewpoint. They involve more calculation than parallel projections, but are often preferred for their greater realism. Note that a parallel projection may be considered as a special case of the perspective projection where the viewpoint is at infinity.

A perspective transformation produces a projection from a viewpoint E onto a given plane. Because you can always move the axes to ensure that the plane coincides with z=0 and the normal from the plane through the point E lies along the z-axis, you may restrict the discussion to this simple case.

Perspective Projection

The above figure shows an example of the perspective projection from the point E at (0,0,-d) to the z=0 plane.

The projection is obtained by joining E to each vertex in turn and finding the intersection of this line with the plane z=0. The vertices are then joined by straight lines to give the wire-frame drawing of the object in the plane.

This method of drawing the object, makes use of some of the well-known properties of perspective projections, namely that straight lines are projected into straight lines and facets ( A facet is a closed sequence of co-planar line segments, a polygon in other words) are projected into facets. Parallel sets of lines may be projected into a set of parallel lines or into a set of lines meeting at the `vanishing point'.

We may consider the equation of the projection either as the result of the transformation matrix or derive it from the following diagram

Consider the diagram first. This shows the y=0 plane with the Ox and Oz axes. The point of projection is E at the point (0,0,-d) on the z-axis, so the distance OE is of length d. The point P (with values x and -z) projects into the point P' while the point Q (with values X and Z) projects into the point Q'.

From the first set of similar triangles, we can see that d/x' = (d-z)/x and so x'=d*x/(d-z)

From the second set of similar triangles, we can see that d/X'=(d+Z)/x and so X'=d*X/(d+Z)

Thus if we are careful to take the correct sign for z in each case, we can quote the general rule:

x' = d*x/(d+z)

and we have a similar position for the y-coordinate when looking at the x=0 plane.

Now let us turn to the transformation matrix. In this case it becomes, 
	X		1	0	0	0		x
	Y	=	0	1	0	0		y
	Z		0	0	0	0		z	
	H		0	0	1/d	1		1
which gives the four equations.

	X = x		Y = y 		Z = 0		H = (z+d)/d

To get back to the homogeneous coordinates, we need to make H=1 and so 
we have to divide throughout by (z+d)/d. This gives:

		 X = d*x/(z+d), 	Y = d*y/(z+d),	Z=0   and   H=1 

Hence we get the same expression for this derivation.

The closer the point of projection, E, is to the object, the more widely divergent are the lines from E to the vertices and the greater the change in size of the projected object. Conversely, the further away we move E, the closer the lines get to a parallel set and the smaller the change in size of the object. Thus we may think of the parallel projection as being an extreme case of perspective when the point of projection E is an infinite distance from both the object and the plane.

This perspective projection is an example of a `single-point perspective' and the consequence of this is shown in the next figure.

The one set of parallel lines forming edges of the cube meet at the vanishing point, while the other sets meet at infinity (i.e. they remain parallel). The transformation matrix for this projection may be written in the form given below, where r = 1/d.


	1 	0 	0 	0 
T1 = 	0 	1 	0 	0 
	0 	0 	0 	0 
	0 	0 	r 	1

When we come to deal with two or three point perspectives, then we have two or three sets of parallel lines meeting at their respective vanishing points. The matrices for these are given below:


	1 	0 	0 	0 		1	0	0	0
T2 = 	0 	1 	0 	0 	T3 = 	0 	1	0	0
	0 	0 	0 	0 		0	0	0	0
	0 	q 	r 	1		p	q	r	1

The following figure shows an example of a three-point perspective.

We now have enough information to specify the form of a general transformation matrix.


		t{11} 	t{12} 	t{13} 	t{14}
	T = 	t{21} 	t{22} 	t{23} 	t{24}
		t{31} 	t{32} 	t{33} 	t{34}
		t{41} 	t{42} 	t{43} 	t{44}

This divides into four areas, each of which relates to a different form of transformation.


			T1	      	|   T3
	T = 	shear, scale & 	      	|  shift
		   rotate	      	|
		  ________________________________
		   T2 usually zero   	|  T4=1		


T2 is zero for all affine transformations and when we are dealing with perspective projections, the number of non-zero elements in T2 will tell us whether it is a one-, two- or three-point perspective.