by William Shoaff with lots of help
Given a point in view space we want to project it along projection lines (projectors)
that meet at a center of projection
Let's pretend we're given a projection plane
The parametric equation of the line from
to
is given by
We want to find the point P along this line which also lies in the
projection plane.
Thus, substitute the parametric line equation into plane equation
and solve for the parameter t, which yields the value where the line
intersects the plane.
Now know t we can calculate the projected point where the projector
intersects the projection plane.
Note denominator for P depends on object point
,
and thus this transformation can not be represented via a matrix
transformation. However, we could compute
Pretend the projection plane is z=0 in view space, that is the plane
in which the eye or camera lens lies.
Place the center of project at a positive distance along the
view space z axis, that is at
.
From the previous equation for t, using
we find
t=-zo/(d-zo), and
To summarize,
The above discussion, while useful, does not tell us how we really
want to approach the view space to perspective space transformation
via a computer implementation of the perspective map.
To do so, let's pretend the view volume, in view coordinates, we want to map is
specified by view angle
Note although we call the near and far planes clipping planes we do not necessarily have to clip against them. However, it may make sense to clip objects that are so far from our eye that they appear as only a few pixels. Ink pen plotters may tear the paper if they draw complex objects over a small area!
The point is not really whether we clip or not. Some view space plane has to map to z=0 in perspective space and another view space plane has to map to z=1 in perspective space. We've simply declared that these by the near z=zn and far z=zfplanes.
Consider the slice of this frustum in the xz plane
We find that
The same mapping works for the y coordinate
This yields the matrix transformation
The perspective view onto
,
,
is given by the matrix
We've looked at perspective projections from their fundamentals. That is, one projects by passing lines from an object to a center of projection through a projection plane. Since each line has a unique direction, the projection in non-linear and can not be represented only using matrices. However, if we introduce homogeneous coordinates and a homogeneous divide we can use a matrix to represent a perspective projection.
We also looked at the usual case where we are projecting onto a plane parallel to the z=0 plane in view space and where the center of projection is on the z axis. The perspective transform in particularly simple in this case.
Finally, we've seen that a good way to implement the perspective
transform is to specify, in view space, a field of view angle
and
near and far planes z=zn and z=zf that map to z=0 and z=1 in
perspective space (after the homogeneous divide).