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
.
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 linear map. Thus,
the map 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
First consider the case where the viewpoint is the origin and
the viewplane is the plane
. The
object should be entirely above the
level, so its
points have
. For each
point
in the object, we need to scale it to make the
third coordinate equal to
. The result is
. In terms of the viewplane coordinates
, this is
(3.2 )
If instead the viewpoint is
for some
, we scale up
by a factor of
instead and get
(3.3 )
Now consider the case where the setup is the other way around:
The viewplane is
and the viewpoint is
.
In the earlier formula, we simply replace
by
to
switch 0 and
as
-values, and we get
, or
equivalently,
(3.4 )
This is logical:
and
have been scaled by an amount that depends on
.
Example. Suppose we want a perspective picture of the cube
on the
-plane from the viewpoint
. This is the case
.
For the vertices
on the top face we get
.
Similarly, for the vertices on the bottom face we get
. Joining up these eight points, you get
the ``square inside a square'' perspective image of the cube. See Figure
.