Theory:


1. Transformations

In case of viewing systems, a change of coordinates incolve both translation and rotation. And in strucutre-deforming transformations, objects are deformed along particulat axes. Shapes can be twisted into a different form.

2. Polygonal representation

The object is represented by a mesh of polygonal facets. The faces of the polyhedron are listed as groups of 4 vertices, i.e. in forms of rectangles or triangles.

3. Viewing system

On the computer, everything is in the form of two dimentional. Thus, a convertion from 3 dimensional world coordinate space to a 2 dimensional representation is necessary.
First, there is a transformation Tview from a world coordinate system to a viewing coordinate system. The next step is the transformation of Tpers projects three dimensional points in view space onto two dimensional view plane. The steps are:

<1> The calculation of normal vector for light reflection.
<2> The transformation from view coordinate to screen coordinate.
<3> The checking of depth:

for every face of the polygon, it will be checked whether it is obscured by another face in front of it. Depth sort algorithm determines the existence of any hidden surfaces. It uses the farthest z coordinate or average of z depths is used to sort polygons:
1. check if the face's x is obscured by any faces
2. check if the face's y is obscured by any faces
3. check if the face is covered by another face above it
4. check if the face covering it is exactly opposite to it
5. check if the projection of the face is hidden
If none of the above is true, an exception is raised.
<4> Quicksort sorts the faces in order according to the z-depth:

m = small; n = large; center = (int)n/2;
while ( m <=n ) {
while ( face[center] is not covered by face[m] && m < large ) m++;
while ( face[n] is not covered by face[center] && n > small ) n++;
if ( m <= n ) swap face[m] and face[n]; }
if ( n >small ) quicksort(0,small);
if ( m < large) quicksort(m,large);