Perspective

We want to model a camera lens positioned at (0,0,f) that is looking toward the origin (0,0,0).

In other words, the camera lens will be f units away from the origin, in the positive z direction, and will be facing toward the -z direction. We will refer to f as the "focal length" of the camera.

We want all objects at z = 0 (that is, any object whose distance from the camera equals the focal length of the camera) to be neither magnified nor reduced in size, while objects that are farther away should appear smaller, and objects that are near should appear larger.

In particular, an object at z = -f should appear half its original size, since it is twice as far away from the camera lens as objects which are at the focal length.

Also, an object at z = f/2 should appear twice its original size, since it is half as far away from the camera lens as objects which are at the focal length.

This is achieved by transforming x and y as follows:

x → fx / (f-z)

y → fy / (f-z)

You can use the above two equations in your homework for this coming class. Try playing around with different values of f, and see how it affects the result.

In order to do rendering in the coming weeks, we will need to care about the value of z as well, one that will keep straight lines straight. Which means we need to find a linear transformation that achieves the above.

A linear (matrix) transformation that produces the desired values of x and y is:

```      1    0    0    0
0    1    0    0
0    0    1    0
0    0  -1/f   1
```
since this matrix will transform (x,y,z,1) → (x,y,z,1-z/f).

If we divide through by the homogeneous coordinate w = (1-z/f), then we get a transformation that does what we want:

(x , y , z)

→ (x / (1-z / f) , y / (1-z / f) , z / (1-z / f))

which equals   (fx / (f-z) , fy / (f-z) , fz / (f-z))