# Do 3d Programs calculate perspective?

Recently I’ve started reading up on colour theory, perspective and such fundamentals.
There are several things I find puzzling, and this question is motivated by the issue ‘How trustworthy are 3D simulations in regards to perspective?’.

From what I understand, how light and our eyes interact basically decide what we perceive as perspective. As in, perspective is an effect/interpretation of what we see, and not real in the way light and objects are.
Therefore, even though I can approximate and express perspective using things like vanishing points and such, I’ve been wondering how a certain point of view’s perspective would be calculated. And from that I came to ask myself how any 3d program that displays models knows how to calculate that?
For example, how does a program know how small and at which position on the screen to display part of an object relative to other parts.

My specific question is: Does a 3d program calculate perspective, and if yes what information does it take, or is perspective merely a side-effect (in the viewers mind) of what is actually calculated/displayed, and if so, what is actually calculated?

I can’t express my question very well I feel, so again the example:
If I have a simple wooden planket model (rectangle) and look at it from different points of view in a program, I could take screenshots and draw the vanishing lines and points for each of these. The side ‘further away’ would look smaller even though in reality the sides are the same. This is what I mean with perspective in this question. In nature that would be an effect of how my eyes work, since the sides are the same size. How about in the simulation? Is it my eyes/mind that cause me to see this perspective or does the program actually calculate it, and if so, how?

I don’t know whether this is the most appropriate se site for my question, I also had the computergraphics se in mind, but I’m not aware of any other art related ones.

### TL;DR = YES!

Ok, this question would be a better fit for computergraphics.SE. But since you ask, here ill answer here with a shorter answer than CG.SE would warrant.

‘How trustworthy are 3D simulations in regards to perspective?’.

As trustworthy as you make them. The standard 3D model is usually manipulated by a 4 by 4 matrix and then divided by perspective (see projection on Wikipedia). This is reasonably accurate, as in as accurate as any 3 point perspective you would draw by hand.

The standard camera model is too perfect though. As it assumes a perfect pinhole camera on a perfect capture plane. As does classical 3 point perspective by the way. A real camera lens has all kinds of problems.

In essence 3D graphic people know how to do all of these non ideal things. It is just a question of how long your willing to wait the image to finish. Raytracers make these effects trivial to solve at the cost of computation speed.

If I have a simple wooden planket model (rectangle) and look at it from different points of view in a program, I could take screenshots and draw the vanishing lines and points for each of these.

Yes, Indeed. You can even do this in reverse and take a picture that is in perceptive and correct it to a flat representation. Anyway the 3d application is perfectly capable of drawing these lines for you no need to manually do this.

Is it my eyes/mind that cause me to see this perspective or does the program actually calculate it, and if so, how?

I dont know how much mathematics you know. Did you do linear algebra in school? But basically like this:

1. You model the points of your object in a local coordinate space.
2. You concatenate the affine transformation matrices that is local space to world space coordinates and from there to camera space coordinates.
3. You add the perspective transformation and then divide by the z distance.

An old animation that i did way back describing the process can be found here (2.5 MB QT movie).