University of California, Berkeley
EECS Dept, CS Division
Jordan Smith SLIDE: Scene Language for
Interactive Dynamic Environments
Prof. Carlo H. Séquin

Home Goals Publications People Gallery Assignments Distributions

Camera Projection Notes

Camera Projections


Shearing for Oblique Projections

In both, parallel and pespective projection, you'll have to handle oblique projection - this is normally done by shearing the X and Y coordinate with the Z coordinate. In the figures below, the ([Xmin, Xmax], [Ymin, Ymax]) fields of the camera frustum statement define a viewing window on the Z = -1 plane. The vector from the eye point (always the origin) to the center of this window ( (Xmax + Xmin)/2, (Ymax + Ymin)/2, -1 ) is the DOP (Direction of Projection). The DOP defines how much oblique shearing must be applied to the view frustum to transform it to the canonical half cube.



Parallel Projection


Perspective Projection

The figure below shows the SLIDE perspective viewing frustum in its full generality, an off axis viewing window.

  1. Shear(DOP)
  2. Scale to Canonical Frustum
  3. Perspective Warp to Canonical Half Cube

    The transformation matrix that applies this perspective transformation is:

    Qwarp<-norm =
    1 0 0 0
    0 1 0 0
    0 0 1/(1+zfront) -zfront/(1+zfront)
    0 0 -1 0
    (as given in Foley and vanDam on p. 275) and its inverse is
    Qwarp<-norm-1 =
    1 0 0 0
    0 1 0 0
    0 0 0 -1
    0 0 -(1+zfront)/zfront -1/zfront

    You can download perspective.slf to your as6/SLIDE directory, or the new version perspective_new.slf. This is an interactive demo of what the perspective warp matrix is doing in a 2D perspective world ( Y Z W ). This example shows the homogeneous W = 1 plane sliced out of the 3D homogeneous space. You can animate the application of the perspective warp matrix and the application of the homogeneous division. You can also display the homogeneous clipping planes.



Parallel Projection


Perspective Projection


Perspective Warp


Qwarp<-norm = SHz(-1) * Sz(-zfront/(1+zfront)) * SHw(-1) * SHz(1)
1 0 0 0
0 1 0 0
0 0 1/(1+zfront) -zfront/(1+zfront)
0 0 -1 0
=
1 0 0 0
0 1 0 0
0 0 1 -1
0 0 0 1
*
1 0 0 0
0 1 0 0
0 0 -zfront/(1+zfront) 0
0 0 0 1
*
1 0 0 0
0 1 0 0
0 0 1 0
0 0 -1 1
*
1 0 0 0
0 1 0 0
0 0 1 1
0 0 0 1

Intercept in 4D

The problem is to find the intersection of a 4D line segment with one of the 4D clipping hyper-planes. This will be made easier because we are only dealing with special hyper-planes which contain the origin.

The parametric equation of a line in 4D is analogous to the parametric equation of a line in 3D. A line segment is defined by two 4D points p0 = [x0, y0, z0, w0] and p1 = [x1, y1, z1, w1]. The equation of the line through these points is then:

L(t) = p0 + t * ( p1 - p0) =
x0 + t * ( x1 - x0 )
y0 + t * ( y1 - y0 )
z0 + t * ( z1 - z0 )
w0 + t * ( w1 - w0 )

t then has the range [0, 1] for the line segment.

The equation of a general hyper-plane in 4D is:

ax + by + cz + dw + e = 0

But all the hyper-planes we will be dealing with contain the origin so e will always be 0. This simplifies the equation to:

ax + by + cz + dw = 0

The clipping hyper-planes which we will be dealing with are:

-w <= x <= w -> x = -w and x = w
-w <= y <= w -> y = -w and y = w
-w <= z <= 0 -> z = -w and z = 0

These clipping hyper-planes will also work for the parallel projection case because the w value will always be 1 under parallel projection. So, if we substitute w = 1 in the previous equations we get the following:

-1 <= x <= 1 -> x = -1 and x = 1
-1 <= y <= 1 -> y = -1 and y = 1
-1 <= z <= 0 -> z = -1 and z = 0

These are the same clipping planes we used to do the 3D clipping against the canonical half cube which we used in our parallel projection viewer.

We can generalize these six hyper-plane equations by the following short hand:

i = BB(i,j) * w

Where i is either is either x, y, or z.
And j is either min or max.
So BB(i,j) is one of the canonical half cube bounding box values:
xmin = -1
xmax = 1
ymin = -1
ymax = 1
zmin = -1
zmax = 0

If we then substitute the appropriate components from our line equation into our generalized hyper-plane equation, we get the following:

i0 + t*(i1 - i0) = BB(i,j) * ( w0 + t*(w1 - w0) )

Solving for t we get the following expression:

t = ( (BB(i,j) * w0) - i0 ) / ( (i1 - i0) - (BB(i,j) * (w1 - w0)) )

To make this a little more concrete, lets set i = x and j = max and then substitute in:

t = ( w0 - x0 ) / ( (x1 - x0) - (w1 - w0) )

To verify that parallel projections will still work lets set all w's = 1:

t = ( BB(i,j) - i0 ) / (i1 - i0)

To make this a little more concrete, lets set i = x and j = max and then substitute in:

t = ( 1 - x0 ) / (x1 - x0)


References




This page was originally built by Jordan Smith.

Last modified: Thursday, 07-Oct-2004 17:43:01 PDT