The Master Space to View Space Map

by William Shoaff with lots of help


Contents

The Master Space to View Space Map

You might want to read Blinn's article on the view transform now, see [Bli88]. You can also listen to an audio of the lecture (Windows Media Audio encoding (wma) file.

1.
PDF version of these notes
2.
Audio file of these notes

Our objective now is to construct the map from model (master, object) space into view space. This is a two step process:

1.
map the object to world space (where all objects are collected into a scene), and
2.
map the world scene to view space.
There is no reason to stop in world space but for convenience we'll first talk about the maps from master to world space and then the maps from world to view space.

The Master Space to World Space Maps

There really is no single map that works here, the graphics designer gets to pick and choose what objects are in the world, where they are placed, their size, and orientation. This is all done by applying a linear or, more generally, an affine map to each object. These types of transformations are described in another section of this course. For review, here's a brief discussion.

Linear Transformations

Linear transformations, in which we are interested, have the form

\begin{displaymath}(x,\,y,\,z)M = (x',\,y',\,z')\end{displaymath}

where M is a $3\times 3$ matrix. Specially, we are interested in scales and rotations.

A scale matrix has the form:

\begin{displaymath}S=\left[\begin{array}{ccc}
s_x & 0 & 0 \\
0 & s_y & 0 \\
0 & 0 & s_z\\
\end{array}\right]\end{displaymath}

which change the size of (enlarging or shrinking) objects.

Rotations are a little more complex. There are three principle rotations: about the x, y, and z axes. There are accomplished as follows:

Rotating $P=[x\:y\:z]$ about the z-axis by $\theta$ radians produces a new point $P'=[x'\:y'\:z']$ where

\begin{displaymath}[x'\: y'\: z']= [x \: y \: z]\left[\begin{array}{rrr}
\cos\t...
...
0 & 0 & 1 \end{array}\right]=[x\:y\:z]R_z = [x\:y\:z]R_{xy}.\end{displaymath}

The notations Rz and Rxy are meant to be mnemonics for ``rotate about z'' and ``rotate from x toward y.''

Rotating $P=[x\:y\:z]$ about the x-axis by $\theta$ radians produces a new point $P'=[x'\:y'\:z']$ where

\begin{displaymath}[x'\: y'\: z']= [x \: y \: z]\left[\begin{array}{rrr}
1 & 0 ...
...s\theta \\ \end{array}\right]
=[x\:y\:z]R_x = [x\:y\:z]R_{yz}.\end{displaymath}

Rotating $P=[x\:y\:z]$ about the y-axis by $\theta$ radians produces a new point $P'=[x'\:y'\:z']$ where

\begin{displaymath}[x'\: y'\: z']= [x \: y \: z]\left[\begin{array}{rrr}
\cos\t...
...s\theta \\ \end{array}\right]
=[x\:y\:z]R_y = [x\:y\:z]R_{zx}.\end{displaymath}

The third major type of transform is a translation. It belongs to a class of transformations called affine. (Note that linear transforms are a subclass of affine transforms.)

Affine Transformations

Affine transformations, in which we are interested, have the form

\begin{displaymath}(x,\,y,\,z)M + (t_x,\,t_y\,t_z) = (x',\,y',\,z')\end{displaymath}

where M is a $3\times 3$ matrix, that is they are rotations and/or scales followed by a translation. It is most convenient to represent affine transforms as a $4\times 4$ matrix acting on a point in normalized homogeneous space, that is a point of the form $(x, \,y,\, z,\, 1)$. This allows a uniform method for representing scales, rotations, and translations; and as we will see later the extension to perspective transforms.

Specifically, we write translations as

\begin{displaymath}T=\left[\begin{array}{cccc}
1 & 0 & 0 & 0\\
0 & 1 & 0 & 0\\
0 & 0 & 1 & 0\\
t_x & t_y & t_z & 1\\
\end{array}\right].\end{displaymath}

Now to map an object from model to world space, a graphics designer decides where the object should be located, scaled, and oriented. That is some combination of translations, scales, and rotations are applied to an object.

The World to View Map

The world can be viewed from any position, looking in any direction, and at any orientation. To define a view we need to specify two points in world space and a direction defining an orientation called up. More precisely, we need to know:


\begin{picture}(285,307)(80,625)
\thicklines
\put(140,600){\vector( 1, 0){120}}...
...
\put(300,710){\makebox(0,0)[lb]{\raisebox{0pt}[0pt][0pt]{ $e$ }}}
\end{picture}

The eye point and look-at point determine a view plane normal

\begin{displaymath}\vec{N} = \frac{a-e}{\vert a-e\vert}\end{displaymath}

that is a unit length vector along the z axis of view coordinates. $\vec{N}$ is well defined as long as you don't look at your eye.

The view plane normal $\vec{N}$ and the eye point e determine a plane orthogonal to $\vec{N}$ containing e. The perpendicular projection of $\vec{V}_{up}$ onto this plane determines the y axis of view coordinates. We'll want to normalize its length to one unit, and we'll call this unit length perpendicular projection $\vec{V}$. It can be computed as

\begin{displaymath}\vec{V} = \frac{\vec{V}_{up} - \langle \vec{N} \cdot \vec{V}_...
...up} - \langle \vec{N} \cdot \vec{V}_{up} \rangle \vec{N}\vert}.\end{displaymath}

Although this expressions seems formidable, it is really easy to understand.

The x axis of view coordinates is, of course, orthogonal to the y and z coordinates, that is, a unit length vector along the x axis of view space can be computed as the cross-product of the vectors $\vec{N}$ and $\vec{V}$. Most computer graphicist set up view space so that it is left-handed. Thus, instead of computing the cross-product in the usual xyz order we compute it in reverse zyx order. We'll call the unit vector along the x axis of view space $\vec{U}$. The left-handed version of $\vec{U}$ is computed by the formula

\begin{displaymath}\vec{U} = \vec{N} \times \vec{V}.\end{displaymath}

All of the above is well and good, but how does it help us derive a transformation from world to view space? The answer is we

1.
translate the eye point e to the origin;
2.
rotate the vector $\vec{N}$ to the z axis;
3.
rotate to place the up vector $\vec{V}_{up}$ in yz plane;
4.
reflect about yz plane to create a left-hand coordinate system.

The translation matrix is given by

\begin{displaymath}T_{e\rightarrow O} = \left[\begin{array}{rrrr}
1 & 0 & 0 & 0...
...
0 & 0 & 1 & 0 \\
-e_x & -e_y & -e_z & 1 \end{array}\right].\end{displaymath}

Now we'll construct a $3\times 3$ rotation-reflection matrix M that performs the other steps outlined above. For convenience let the three columns of M be called M1, M2, and M3:

\begin{displaymath}M = [M_1 \: M_2 \: M_3].\end{displaymath}

M rotates the the view plane normal $\vec{N}$ to the z axis, that is,

\begin{displaymath}\vec{N}M = (0,0,1).\end{displaymath}

Multiplying both sides of this equation by the inverse of M(which, recall, is the transpose of M) yields

\begin{displaymath}\vec{N} = (0,0,1)M^T = (m_{13},\,m_{23},\,m_{33}) = M_3.\end{displaymath}

That is, the third column M3 of M is $\vec{N}$

M rotates the up vector into the yz plane. That is,

\begin{displaymath}\vec{V}_{up}M = (0,\,A,\,B)\end{displaymath}

for some $A,\,B$. Again, multiply both sides of this equation by M-1=MT to get

\begin{displaymath}\vec{V}_{up} = (0,\,A,\,B)M^T = AM_2 + BM_3.\end{displaymath}

From which we can solve for the second column of M

\begin{displaymath}M_2 = \frac{\vec{V}_{up} - B M_3}{A},\end{displaymath}

but we need to know the constants A and B to know M2 completely.

We have specified that the up vector has unit length, and so we know

A2+B2=1.

So if we know one of A of B we will know the other. The trick to finding B is to compute the inner product of $\vec{V}_{up}$ with M3

\begin{displaymath}\langle \vec{V}_{up} \cdot M_3 \rangle =
A \langle M_2 \cdot M_3\rangle + B \langle M_3 \cdot m_3\rangle = B,\end{displaymath}

where we've used the fact that the inner product of M3 with itself is 1 and the inner product of M3 with M2 is 0 (these are obvious if you understand that the inverse of M is its transpose and matrix multiplication is a series of inner products). Since B is known we fine

\begin{displaymath}A = \sqrt{1-B^2}\end{displaymath}

. Thus,

  \begin{eqnarray*}
M_2 = \frac{\vec{V}_{up} - \langle \vec{V}_{up}\cdot \vec{N}\r...
...vec{N}}%
{\sqrt{1-\langle \vec{V}_{up} \cdot \vec{N}}\rangle^2},
\end{eqnarray*}


which is perfectly good mathematics unless you don't start with a unit length up vector.

Finally, we can compute M1 the first column of M via cross products:

\begin{eqnarray*}M_1 & = & M_3\times M_2 \\
& = & \frac{\vec{N}\times \vec{V}_{up}}{\sqrt{1-\langle\vec{V}_{up}\cdot\vec{N}\rangle^2}}\\
\end{eqnarray*}


To summarize, the view transform from world to view space is given by

\begin{displaymath}M_{world \rightarrow view} =
\left[\begin{array}{rrrr}
1 &...
...1} & m_{32} & m_{33} & 0 \\
0 & 0 & 0 & 1 \end{array}\right],\end{displaymath}

where

\begin{eqnarray*}(m_{13}, \,m_{23},\,m_{33}) & = & (a_x-e_x,\,a_y-e_y,\,a_z-e_z)...
...la}{m2}}\\
(m_{11}, \,m_{21},\,m_{31}) & = & M_3 \times M_2 \\
\end{eqnarray*}


Conclusions

The map from model space to view space is composed of modeling transforms that place objects in the world and a view transform that presents the world as seen from a virtual camera. The modeling transforms are made from scales, rotations, and translations and can vary from one object to another. The view transform is made from a translation and a rotation-reflection. View space is left-handed.

Bibliography

Bli88
Jim Blinn.
Where am i? what am i looking at?
IEEE Computer Graphics and Applications, 8(4):76 - 81, July 1988.



William D. Shoaff
2002-02-22