CAGD-banner.gif
On-Line Geometric Modeling Notes
FRAMES


In computer graphics we manipulate objects. These may include light sources, cameras, and objects in our scenes. Each of these is likely to be defined in its own coordinate system and then placed within the scene we are modeling. We must be able to relate these coordinate systems, both to a global coordinate system and to each other. We place coordinate systems into an affine space through the use of frames.

We first discuss the definition of a frame and give several examples of frames including the well known Cartesian Frame. A matrix representation of points and vectors under a given frame is developed and utilized to discuss the conversion of coordinates between frames The method of conversion is developed first through a specific two dimensional example which shows that the problem can be solved by developing a $ 3 \times 3$ conversion matrix. The general n-dimensional case is then discussed. We conclude with a discussion of how to generate this conversion matrix.

pdficonsmall.gif For a pdf version of these notes look here.



Definition of a Frame

Let $ {\cal A} $ be an affine space of dimension $ n$. Let $ {\bf O} $ be a point in this space and let $ {\vec v} _1, {\vec v} _2, ..., {\vec v} _n$ be any basis for $ {\cal A} $. We call the collection $ {\cal F} = ( {\vec v} _1, {\vec v} _2, ..., {\vec v} _n, {\bf O} )$ a frame for $ {\cal A} $. Frames form coordinate systems in our affine space. That is, if we consider a point $ {\bf P} $, $ {\bf P} $ can be written as $ {\bf O} +
{\vec v} $, where $ {\bf O} $ is the origin of the frame and $ {\vec v} $ is a vector. Since the $ {\vec v} _1, {\vec v} _2, ..., {\vec v} _n$ forms a basis for $ {\cal A} $, we have that the vector $ {\vec v} $ can be written uniquely as

$\displaystyle {\vec v} \: = \: c_1 {\vec v} _1 + c_2 {\vec v} _2 + \cdots + c_n {\vec v} _n
$

and so the point $ {\bf P} $ can be written uniquely as

$\displaystyle {\bf P} \: = \: c_1 {\vec v} _1 + c_2 {\vec v} _2 + \cdots + c_n {\vec v} _n + {\bf O}
$

The set of values $ (c_1, c_2, ..., c_n)$ are the coordinates of $ {\bf P} $ relative to the frame $ {\cal F} $.


Examples of Frames

Two-dimensional examples of frames are fairly straightforward to produce. We will denote the frames as $ ( {\vec u} , {\vec v} , {\bf O} )$.


Matrix representation of Points and Vectors

Points and vectors can be uniquely identified by the coordinates relative to a specific frame. Given a frame $ ( {\vec v} _1, {\vec v} _2, ..., {\vec v} _n, {\bf O} )$ in an affine space $ {\cal A} $, we can write a point $ {\bf P} $ uniquely as

$\displaystyle {\bf P} \: = \: c_1 {\vec v} _1 + c_2 {\vec v} _2 + \cdots + c_n {\vec v} _n + {\bf O}
$

This can also be written as

$\displaystyle {\bf P} \: = \:
\left[ \begin{array}{ccccc}
c_1 & c_2 & \cdots & ...
..._1 \\  {\vec v} _2 \\  \vdots \\  {\vec v} _n \\  {\bf O}
\end{array} \right]
$

Similarly, since the vectors of our affine space form a vector space, we can write a vector $ {\vec v} $ uniquely as

$\displaystyle {\vec v} \: = \: c_1 {\vec v} _1 + c_2 {\vec v} _2 + \cdots + c_n {\vec v} _n
$

and this can be written as

$\displaystyle {\bf P} \: = \:
\left[ \begin{array}{ccccc}
c_1 & c_2 & \cdots & ...
..._1 \\  {\vec v} _2 \\  \vdots \\  {\vec v} _n \\  {\bf O}
\end{array} \right]
$

Thus, points are represented as row vectors whose last component is $ 1$ and vectors are represented as row vectors whose last component is 0 (zero).


Converting Between Frames

A useful technique is, when given two different frames, to take a point that has a certain set of coordinates in one frame and find its coordinates in the second frame. Most readers will do this routinely, relating points back to the Cartesian frame. But what if the second frame is not the Cartesian frame?


It is useful to study a two dimensional example of this process before proceeding in general.

Consider the two frames $ ( {\vec u} _1, {\vec v} _1, {\bf O} _1)$ and $ ( {\vec u} _2, {\vec v} _2,
{\bf O} _2)$ where

$\displaystyle {\vec u} _1$ $\displaystyle = <1,0>$ $\displaystyle \qquad {\vec u} _2$ $\displaystyle = <1,0>$    
$\displaystyle {\vec v} _1$ $\displaystyle = <1,1>$ $\displaystyle \qquad {\vec v} _2$ $\displaystyle = <0,2>$    
$\displaystyle {\bf O} _1$ $\displaystyle = <0,0>$ $\displaystyle \qquad {\bf O} _2$ $\displaystyle = <2,2>$    

These frames are shown in the figure below

\includegraphics {figures/frame-1}

Suppose we have the point $ {\bf P} $, with coordinates $ ( 3, 2 )$ in the frame $ ( {\vec u} _1, {\vec v} _1, {\bf O} _1)$. What are the coordinates of the point in the frame $ ( {\vec u} _2, {\vec v} _2, {\bf O} _2)$?

This is straightforward to calculate using the matrix notation for the points.

\begin{displaymath}\begin{aligned}3 {\vec u} _1 + 2 {\vec v} _1 + {\bf O} _1 & =...
...\  {\vec v} _2 \\  {\bf O} _2 \end{array} \right] \end{aligned}\end{displaymath}

and therefore the new coordinate is $ (3,0)$ under the frame $ ( {\vec u} _2, {\vec v} _2, {\bf O} _2)$.

Now carefully note what we did in this calculation. First we wrote the point in the matrix notation for the frame $ ( {\vec u} _1, {\vec v} _1, {\bf O} _1)$. Then we wrote the vectors of the first frame in terms of the vectors of the second frame - and we can do this since the vectors of the second frame (any frame actually) form a basis for the space of vectors. Then we wrote the origin $ {\bf O} _1$ in terms of the origin and vectors of the second frame. This column vector, expressing the first frame in terms of the second, was converted to the product of a $ 3 \times 3$ matrix and the column vector representing the second frame. We then multiplied the $ 3 \times 3$ matrix times the initial coordinate to obtain the result.

This can be done with any coordinate from the first frame, as the $ 3 \times 3$ matrix generated will be the same in every case. That is, given a coordinate $ (u,v)$ from the first frame, we can convert it to a coordinate for the second frame by simply calculating

$\displaystyle \left[ \begin{array}{ccc}
u & v & 1
\end{array} \right]
\left[ \...
...}{ccc}
1 & 0 & 0 \\
1 & \frac{1}{2} & 0 \\
-2 & -1 & 1
\end{array} \right]
$


To convert coordinates from one frame to another in $ n$-dimensional space proceeds in the same way as the example above.

Suppose a point $ {\bf P} $ has coordinates $ (c_1, c_2, ..., c_n, 1)$ relative to some frame $ {\cal F} = ( {\vec v} _1, {\vec v} _2, ..., {\vec v} _n, {\bf O} )$. What would be the coordinates of $ {\bf P} $ relative to another frame $ {\cal F} ' = ( {\vec v} _1', {\vec v} _2', ..., {\vec v} _n', {\bf O} ')$?

Well since $ ( {\vec v} _1', {\vec v} _2', ..., {\vec v} _n')$ is a basis, we can write each of the vectors $ {\vec v} _1, {\vec v} _2, ..., {\vec v} _n$ uniquely in terms of the $ {\vec v} _i'$. In addition, since $ {\bf P} - {\bf O} $ is a vector, we can also write $ {\bf O} $ uniquely in terms of the $ {\vec v} _i'$ and $ {\bf O} '$. Thus we can calculate coefficients $ e_{i,j}$ defined by

\begin{displaymath}\begin{aligned}{\vec v} _i & = e_{i,1} {\vec v} _1' + e_{i,2} {\vec v} _2' + \cdots + e_{i,n} {\vec v} _n' \\  \end{aligned}\end{displaymath}

for $ i = 1, 2, ..., n$ and

\begin{displaymath}\begin{aligned}{\bf O} & = e_{n+1,1} {\vec v} _1' + e_{n+1,2}...
..._2' + \cdots + e_{n+1,n} {\vec v} _n' + {\bf O} ' \end{aligned}\end{displaymath}

So now we can write

\begin{displaymath}\begin{aligned}c_1 {\vec v} _1 + c_2 {\vec v} _2 + \cdots + c...
...\  {\vec v} _n' \\  {\bf O} ' \end{array} \right] \end{aligned}\end{displaymath}

and since the vectors $ ( {\vec v} _1', {\vec v} _2', ..., {\vec v} _n')$ are linearly independent we have that the coordinates $ (c_1, c_2, ..., c_n)$ of the point in the second frame is

$\displaystyle \left[ \begin{array}{ccccc}
c_1' & c_2' & \cdots & c_n' & 1
\end{...
...} & 0 \\
e_{n+1,1} & e_{n+1,2} & \cdots & e_{n+1,n} & 1
\end{array} \right]
$

Thus the change of coordinates is accomplished via a matrix multiplication. We note that the rows of the matrix consist of the coordinates of the elements of the old frame $ {\cal F} $ relative to the new frame $ {\cal F} '$.

We also note that if we consider the frames in three dimensional space (i.e. $ n=3$), the matrix is $ 4 \times 4$.


So how do we calculate the matrix

$\displaystyle \left[ \begin{array}{ccccc}
e_{1,1} & e_{1,2} & \cdots & e_{1,n} ...
...} & 0 \\
e_{n+1,1} & e_{n+1,2} & \cdots & e_{n+1,n} & 1
\end{array} \right]
$

which is required for the conversion of the coordinates of a point in one frame to those of another? We use Cramer's Rule.

Since most of the calculations we are required to do are in 3 dimensions, we will present the techniques for calculating the matrix in this special case - where the frames will now be denoted as $ ( {\vec u} _1, {\vec v} _1, {\vec w} _1, {\bf O} _1)$ and $ ( {\vec u} _2, {\vec v} _2, {\vec w} _2, {\bf O} _2)$ and the matrix will be

$\displaystyle \left[ \begin{array}{cccc}
e_{1,1} & e_{1,2} & e_{1,3} & 0 \\
e...
..._{3,2} & e_{3,3} & 0 \\
e_{4,1} & e_{4,2} & e_{4,3} & 1
\end{array} \right]
$

So how do we find the values $ e_{i,j}$?

Given any frame $ ( {\vec u} , {\vec v} , {\vec w} , {\bf O} )$, and a vector $ {\vec t} $, I know that $ {\vec t} = u {\vec u} + v {\vec v} + w {\vec w} $ for some $ u$, $ v$ and $ w$. Utilizing Cramer's Rule, I can calculate these coordinates directly by the following process: If we define

\begin{displaymath}\begin{aligned}D & = {\vec u} \cdot ( {\vec v} \times {\vec w...
...3 & = {\vec u} \cdot ( {\vec v} \times {\vec t} ) \end{aligned}\end{displaymath}

then we can calculate

\begin{displaymath}\begin{aligned}u & = \frac{D_1}{D} \\  v & = \frac{D_2}{D} \\  w & = \frac{D_3}{D} \end{aligned}\end{displaymath}

Utilizing this process, we can let $ ( {\vec u} , {\vec v} , {\vec w} , {\bf O} ) = ( {\vec u} _2, {\vec v} _2, {\vec w} _2, {\bf O} _2)$, and we can let $ {\vec t} = {\vec u} _1$ and calculate $ e_{1,1}$, $ e_{1,2}$ and $ e_{1,3}$ ; we can let $ {\vec t} = {\vec v} _1$ and calculate $ e_{2,1}$, $ e_{2,2}$ and $ e_{2,3}$ ; we can let $ {\vec t} = {\vec w} _1$ and calculate $ e_{3,1}$, $ e_{3,2}$ and finally we can let $ {\vec t} = {\bf O} _2- {\bf O} _1$ and calculate $ e_{4,1}$, $ e_{4,2}$ and $ e_{4,3}$.

So using Cramer's rule, the calculations are straightforward and consist of taking a few cross products and dot products.

See the section on Cramer's Rule for more information when the frames are orthonormal.


\begin{singlespace}
\noindent
\footnotesize\bfseries All contents copyright (c) ...
...ment, University of California, Davis \\
All rights reserved.
\end{singlespace}


Ken Joy
2000-11-28