3d

Contents :

Why things look smaller at some distance
Take a pen. When you put it close to your eyes it will look big. The angle between the top and the bottom of the pen will be big. If you move away a bit, the pen will look smaller. That's because the angle between the top is smaller.

Let's make some algorithms
All you have to do when you want to draw a line in 3d is to calculate the coordinates in 2d for the line. This can be done by calculate the angles, and use them when you calculate the new 2d coordinates. The 2d points have two components : x and y. The 3d points have three coordinates : x, y and z. All we have to do is to remove the z coordinate, and change x and y a bit. To calculate what angle the new point would have we use the following formulas :
xangle=x/(z+dist)
yangle=y/(z+dist)
The dist tells you the distance to the screen (for the eye). Then you change the z value to 0. The angles and the dist have the same values as before, so you must change the x and y values. The values can be calculated this way :
xnew=dist*xold/(zold+dist)
ynew=dist*yold/(zold+dist)
xnew and ynew is the new values for x and y. xold and yold is the old values for x and y. zold has the same value as z had before it was changed to 0.

This document was created 1996-12-21