CS488 - Introduction to Computer Graphics - Lecture 7
Comments and Questions
- View frame.
Device Transformations
Windows
On the view plane
Viewports
On the device
Normalized Device Coordinates
For the device, obviously
Perspective Projection
Projection from a 1D space to a 1D space.
- We draw it in two dimensions (Why?)
- Pencil of lines through a projection point: all points on a line are
the `same' point.
- Affine transformations from 1D to 1D
- What can an affine transformation do in 1D? Translate, reflect,
scale.
- Projection points at infinity translate.
- A projection point between the origins reflects.
- Projection points on the line that joins the origins, and outside
the lines, scale.
- What do other projection points do?
What does this type of projection have to do with computer graphics?
- Perspective projection maps 3D world space to the 2D viewplane.
- What happens if the projection point is on one of the lines?
- Put the projection point anywhere
- on one of the lines.
- at infinity
- The general form of a projection
- Mobius transformation: x2 = (a x1 + b ) / ( c x1 + d )
- Really is the general form
- x' * z = x * z'
- x = y * cos(theta), z = z1 + y * sin(theta), x' = y' *
cos(theta'), z' = z2 + y' * sin(theta')
- y' * cos(theta') * ( z1 + y * sin(theta) ) = y * cos(theta) * (
z2 + y' * sin(theta') )
- y' * ( z1 * cos(theta) + y * sin(theta - theta') ) = y *
cos(theta)
- y' = y * cos(theta) / ( z1 * cos(theta) + y * sin(theta -
theta') )
- But the origins of the lines do not necessarily lie on the same
ray.
- 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.
- 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).
Projection from 2D to 1D
We can draw it in 2D (Why?)
- three components:
- plane, containing the stuff to be projected
- line, onto which the stuff will be projected
- point of projection
all must lie in the same plane
- projection point in/out of the plane
- line in out/of the plane
How is it done?
- Define a coordinate frame, the view coordinates,
- origin at the projection point
- z-axis perpendicular to the line
- x-axis parallel to the line
- Transform points in the plane into view coordinates
- (xw, zw, 1) -> (xv, zv, 1) using an affine transformation
- In the view coordinates, x' = z' * ( xv / zv )
- But xv = a * xw + b * zw + c, and zv = d * xw + e * zw + f
- 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,
- Near plane goes to z' = -1.
- Far plane goes to z' = 1
- Top plane goes to x' = 1
- 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
- zn: z coordinate of the near plane
- zf: z coordinate of the far plane
- mu: slope of the upper limit of the frustrum
- md: slope of the lower limit of the frustrum
we can map the four planes.
- (x, zn, 1 ) -> (sx', -s, s )
- (x, zf, 1 ) -> (tx'', t, t )
- (mu*z, z, 1 ) -> (u, uz', u )
- (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)
- z = zf
- z = zn
- What maps to zero? z' = 2*zf*zn / (zf + zn )
Note the possible numeric problems.
- z -> +0
- z -> -0
- z -> infinity, z' = (zf + zn) / (zf - zn)
Return to: