# 3D Wireframes

The pictures on this page can be viewed with a green/red pair of glasses. The right eye is covered with a green foil. Therefore, it can not see the green lines, while the red lines become dark. With the red foil in front of the left eye, the red lines become invisible and the green lines become almost black.

## Calculating the projection of a 3D object to the sceen

It is quite easy to calculate the 3D projection of a wireframe onto the computer screen. First we reduce the problem to the 2-dimensional plane in which the eyes are located, perpendicular to the computer sceen.

The point (x, z) of the source object is indicated by (x_{s}, z_{s}) while the location of the observer is indicated by (x_{o}, z_{o}).

Off course, there are two eyes. We have to apply similar projections for the left and right eye. For simplicity, the equations are given here for a single eye. The only thing that changes is the x-position of the second eye.

For the following argumentation it does not matter if the object is in front or behind the computer screen.

The projection of the source point (x_{s}, z_{s}) on the sceen is (x_{p}) and can be found by the intersection of the line from (x_{s}, z_{s}) to (x_{o}, z_{o}) with the screen. Two congruent triangles result into the equation

which can easily be modified into

.

The same as we did for the xz-plane is valid for the yz-plane. The equation becomes

.

Normally we fix the position of the eyes and say x_{o-left}=-d/2 and x_{o-right}=d/2 with d the distance between the eyes (approximately 6 cm). In addition, the mutual y_{o}-position of the eyes can be set to 0 and the distance z_{o} to the screen to -l (negative!). However, in that case we can not simply make the viewer virtually move with respect to the object (although this is a relative thing).

These equations are implemented in MathCad 6.0 including some functions to generate wireframes for common shapes.

## Viewing the files

Each wire consists of four points: two for a left-eye wire and two for the righ-eye wire. The MathCad worksheet generates ASCII files with eight numbers per line. The meaning of the numbers is: x1-left, y1-left, x2-left, y2-left, x1-right, y1-right, x2-right, y2-right.

A simple file viewer was programmed which can read the .prn ASCII files and view them on the screen. At this moment, the numbers in the file must be separted by spaces and only fractional numbers (no exponents) can be used.