Title: Chapters 5'7 and 5'8: Projection Matrices
1Chapters 5.7 and 5.8Projection Matrices
- Todd Bryan
- 1 March 2001
- CS594 Scientific Visualization
2Two Types of Projections
- Parallel Projections objects are viewed as
though the camera were an infinite distance from
the scene - Perspective Projections real-world projections,
where parallelism is not preserved. All lines
have a vanishing point.
3Parallel Projection Matrices
- We use projection normalization, which converts
all projections to a standard viewing volume and
then applies a simple orthogonal projection
matrix. - The canonical view volume is a cube centered on
the origin with sides
x 1 y 1 z 1
4Transforming to the canonical volume
- First, we must translate the volume to the origin
- Second, we scale the volume to the canonical
dimensions - This is done with the projection matrix
5Setting up parallel projections in OpenGL
- glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0)
- If we want to define a different viewing volume,
the function call looks like glOrtho(-7.0, 7.0,
-3.0, 5.0, -2.0, 13.0) - If the defined volume is different from the
canonical viewing volume, OpenGL must map the
viewing volume back to the canonical box.
6Transformation Matrices
Scaling Matrix
Transformation Matrix
Result
7Oblique Projections
Up to this point we have assumed the projectors
the lines from object to the viewing plane are
all orthogonal to the viewing plane. Oblique
projections are allowed in OpenGL. They are
equivalent to a shearing of each object in the
viewing volume. A shearing matrix is
concatenated to the perspective matrix.
8Envisioning Oblique Projections
- The direction of projection IS NOT orthogonal to
the projection plane.
9Concatenating the Shearing Matrix
- theta and phi are the projection plane rotation
angles relative to the x and y axes - We concatenate H to ST and then use, again, the
simple orthogonal projection
10Perspective Projections
In a perspective projection our viewing volume
becomes a truncated pyramid (a frustum) which
must be distorted to our canonical volume before
we may apply the orthogonal projection.
11The Perspective Normalization Matrix
This matrix converts the frustum volume to a
right parallelepiped, to which we can then apply
an orthographic projection.
12Perspective Projections in OpenGL
- glFrustum(5.0,-5.0,10.0,10.0,3.0,3.0)
- OpenGL does not restrict us to symmetric
frustums. - The glFrustum() call requires both z parameters
(near and far) to be positive i.e., the
projection plane must be in front of the camera.