# Perspective Projection

What is a projection?

• a linear' mapping of points to points
• linear' in the sense that lines map to lines
• not linear' in the sense that a projection automatically commutes with addition
• Affine transformations are linear in both senses
• based on a centre of projection
• which might be at infinity
• relevance to computer graphics?
• importance of two dimensions in everyday life. (Lots here to think about!)

Projective transformations are a superset of affine transformations.

1. They do not preserve ratios of distance.
2. They do not preserve affine combinations.
3. They do not map vectors.
4. They do preserve the cross ratio.

Show 1D transformation on the board

1. Illustration in 2D. What does this mean? (Hint. homogeneous coordinates)
2. Projection point on one of the lines.
3. Relevance of the intersection point of two lines.
4. How the transformation changes as the projection point moves around.

#### General projections from 1D to 1D

1. Put the projection point anywhere
• on one of the lines.
• at infinity
2. The general form of a projection
• Mobius transformation: x' = (a*x + b ) / ( c*x + d )
• Really is the general form
1. A general point on one line is O + x*i, on the other line, O' + x'*i'.
2. A general point P is the projection point.
3. It's a projection iff (O + x*i - P) \dot (O' + x' * i' - P) = 0. Why?
4. Solve for x'

x' = (x * (i \dot (P - O') - (P - O) \ldot (P - O') ) / ( x * (i \dot i') - (P - O) \dot i' )

• Compositions of Mobius transformation are Mobius transformations
• The inverse of a Mobius transformation is a Mobius transformation
• A Mobius transformation is the product of a translation, a reflective inversion, a dilated rotation, and a translation.
3. Matrix form of the Mobius transformation
/     \
| a b |
| c d |
\     /

The composition of Mobius transformations is the multiplication of matrices (up to a multiplicative constant - Why?).

4. What if P is on one of the lines?
1. P = O' + y*i'
2. Do a little algebra...
3. x' = y'
• The matrix is singular.
• We can work out that it must be
/     \
| 0 y |
| 0 1 |
\     /
4. Draw a picture.

This is actually a projection from 1D to 0D.

#### Projection from 2D to 1D

We can draw it in 2D (Why?)

1. three components:
1. plane, containing the stuff to be projected
2. line, onto which the stuff will be projected
3. point of projection

all must lie in the same plane

2. projection point in/out of the plane
3. line in out/of the plane

How is it done?

1. Define a coordinate frame, the view coordinates,
1. origin at the projection point
2. z-axis perpendicular to the line
3. x-axis parallel to the line
2. Transform points in the plane into view coordinates
1. (xw, zw, 1) -> (xv, zv, 1) using an affine transformation
2. In the view coordinates, x' = z' * ( xv / zv )
3. But xv = a * xw + b * zw + c, and zv = d * xw + e * zw + f
4. Once again we have a Mobius transformation

#### Projection from 2D to 2D

We don't want to throw away z, so we'll do a 2D to 2D projection:

• view frustrum to cube centred on the origin

That is,

1. Near plane goes to z' = -1.
2. Far plane goes to z' = 1
3. Top plane goes to x' = 1
4. Bottom plane goes to x' = -1

Represent the Mobius transformation as a matrix

/       \
| a b c |
| d e f |
| g h i |
\       /

Then, using the code

1. zn: z coordinate of the near plane
2. zf: z coordinate of the far plane
3. mu: slope of the upper limit of the frustrum
4. md: slope of the lower limit of the frustrum

we can map the four planes.

1. (x, zn, 1 ) -> (sx', -s, s )
2. (x, zf, 1 ) -> (tx'', t, t )
3. (mu*z, z, 1 ) -> (u, uz', u )
4. (md*z, z, 1 ) -> (-v, vz'', v )

Each of these gives two ordinary linear equations. (Why?) Just the right number. (Why?) Solve them.

The result is

/                                               \
| 1 (mu + md) / (mu - md)           0           |
| 0 (zf + fn) / (zf - zn)  -2*zf*zn / (zf - zn) |
| 0           1                     0           |
\                                               /`

Exercise. Check that this matrix creates the correct Mobius transformation.

Exercise. Compare this matrix to the one in the notes. It should be the same with the y row and column deleted. Why is it different?

Exercise. Solve the equations.

Exercise. Show that our 2D to 2D projection, followed by orthogonal projection is the same as the 2D to 1D projection just above.

Exercise. Extend these results to 3D, and compare to the matrices given in the notes.

#### Properties of this Projection

z' -> (z*(zf + zn) -2*zf*zn ) / z*(zf - zn)

1. z = zf
2. z = zn
3. What maps to zero? z' = 2*zf*zn / (zf + zn )

Note the possible numeric problems.

4. z -> +0
5. z -> -0

z -> infinity, z' = (zf + zn) / (zf - zn)