The object is given as points in
R. For an object described
by line segments and polygons, all you need is the vertices; the images
of the vertices can be connected up with line segments just as the
vertices were. (Again, this ignores the question of hidden lines.)
The image is in the -plane, which really consists of points
in
R
, but we'd like images as points in
R
so that they are ready to plot on paper or on a screen.
(I) Orthographic
Easy:
.
(II) Oblique
Here the rays are parallel and slanted. To describe the
direction of the rays, we use a vector
V. It turns out to
be easiest if
V is multiplied by a scalar to make the third
coordinate 1; this will still describe the same rays Thus, we
write
V. (The viewpoint is at infinity with
homogeneous coordinates
.)
A good method is to apply a viewing transformation to make the rays
perpendicular to the viewplane while leaving the viewplane alone. After
applying this transformation to the object, we are back in Case (I).
See Figure .
Since the origin stays fixed and parallel lines stay parallel,
the transformation is a homogeneous linear transformation. Thus,
the transformation will be given by a
matrix
taking
,
(since these are both in the viewplane, which stays fixed), and
(to make
V perpendicular to the
-plane).
Notice that it would be easier if the transformation did the
opposite, since then we'd have images of standard basis vectors.
So, let be a
matrix taking
Therefore
. Since
is
the inverse of
, we have
.
(Here we can use the special method of taking inverses of matrices that
are like except in the off-diagonal entries of one row or one
column.)
Now, to find the image of a point, just multiply by and then
project orthographically:
, or briefly,
3.1 .
In practice, you can either apply this method with the matrix multiplication
or else program the final formula
. You
can think of this formula as saying that the image of
consists
of
but offset linearly somewhat, depending on
. See Figure
.
Example: (a) Find the viewing transformation for an oblique projection
from the direction . (b) Under this projection, find the
image of the
cube with vertices
.
Solution: (a) Scaling we get
V
, so
the viewing matrix is
.
(b) The top face, with points
, goes to
points
. The bottom face, with points
goes to points
.
In
R
, these are
squares offset from one
another. Connect them up and you have the traditional oblique
picture of a cube, as shown in Figure
.
(Notice that in this example the cube straddles the viewplane,
but this has no effect on the formulas. Rather, there is one
formula, and it works no matter whether is positive or
negative.)
(III) Perspective
Let's consider just the case where the viewpoint is on the -axis,
so it has the form
for some height
. The object should
lie entirely below this height.
Following the idea used for oblique projections, let's try to find a ``viewing transformation'' that changes the picture to an orthographic projection. This time the viewpoint is an ordinary point and needs to be changed to a point at infinity, so we need to use a projective transformation.
Discussion.
Recall that the key points for handling projective transformations are
, at infinity on the
-axis,
, at infinity on the
-axis,
, at infinity on the
-axis,
, the origin.
(There was also , but we won't need it.)
The given viewpoint is
, but it turns
out to be best to use the equivalent homogeneous coordinates
. The new viewpoint, at infinity on the
-axis, is to be
. Since
are in the
-plane,
they should stay fixed. Then we want to find a
matrix
that gives a projective transformation taking
,
,
,
.
Notice that it is easy to find a
matrix
to go in
the opposite direction, since the coordinates of
are
standard basis vectors in
R
: Just let the rows of
be the images of these standard basis vectors, so that
. Then
,
again since is like
except for the off-diagonal entries in
one row.
gives the viewing transformation.
Now, under the viewing transformation,
. To find the
equivalent ordinary point, divide through by the last homogeneous
coordinate, to get
. Finally, we need to project
orthographically by discarding the third coordinate. This gives the
final result that
As before, you can either apply this method as a formula, or actually
transform points with a viewing transformation and then project. Since
we assumed that the object lies below the height of the viewpoint,
the denominator
is always positive. See Figure
.
Example. Suppose we want a perspective picture of the cube
on the
-plane from the viewpoint
. This is the case
. Using the perspective
transformation, for the vertices
on the top face
we get
, which projects orthographically
to
.
Similarly, for the vertices on the bottom face we get
, which projects orthographically
to
. Joining up these eight points, you get
the ``square inside a square'' perspective image of the cube. See Figure
.