banner.gif
On-Line Computer Graphics Notes
COORDINATE CONVERSION
BETWEEN THE CARTESIAN FRAME
AND AN ARBITRARY FRAME


Overview

Given two frames in three-dimensional space, it is possible to develop a $ 4 \times 4$ matrix that converts coordinates from one frame to coordinates of another. Here we discuss the special case of converting the coordinates of points of an object specified in the Cartesian frame to a local coordinate system specified by an arbitrary frame. This conversion matrix is useful in the construction of complex transformations, as in many cases it is worthwhile to first convert to the Cartesian frame, do our operations in this well-known frame, and then utilize this transformation to convert back.

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


The Problem

Suppose we are given a Frame $ {\cal F} = ( {\vec u} , {\vec v} , {\vec w} , {\bf O} )$ and we let $ {\cal F}_C $ be the Cartesian frame

$\displaystyle (<1,0,0>,<0,1,0>,<0,0,1>,(0,0,0))
$

\includegraphics {figures/frame-to-frame}

If we have a point $ {\bf P} $ with coordinates $ (x,y,z)$ in the Cartesian frame, what local coordinates does this point have with respect to the frame $ {\cal F} $?


Developing the Conversion Matrix

How do we solve this problem? Well, we wish to find coordinates $ (u,v,w)$, so that

$\displaystyle \left[
\begin{array}{cccc}
u & v & w & 1
\end{array}\right]
\left...
...in{array}{c}
<1,0,0> \\
<0,1,0> \\
<0,0,1> \\
(0,0,0)
\end{array}\right]
$

We know that that vectors $ {\vec u} $, $ {\vec v} $ and $ {\vec w} $ are linearly independent and form a basis for the vector space of vectors in $ \Re^3$. Therefore, we can write each of $ <1,0,0>$, $ <0,1,0>$ and $ <0,0,1>$ as a linear combination of these basis vectors as follows:

$\displaystyle <1,0,0>$ $\displaystyle = e_{1,1} {\vec u} + e_{1,2} {\vec v} + e_{1,3} {\vec w}$    
$\displaystyle <0,1,0>$ $\displaystyle = e_{2,1} {\vec u} + e_{2,2} {\vec v} + e_{2,3} {\vec w}$    
$\displaystyle <0,0,1>$ $\displaystyle = e_{3,1} {\vec u} + e_{3,2} {\vec v} + e_{3,3} {\vec w}$    

where the $ e_{1,1}, e_{1,2}, ..., e_{3,3}$ are constants. In addition, since $ (0,0,0)- {\bf O} $ is a vector, we can find constants $ e_{4,1}, e_{4,2},$   and$ e_{4,3}$ so that the point $ (0,0,0)$ can be written as

$\displaystyle (0,0,0) \: = \: e_{4,1} {\vec u} + e_{4,2} {\vec v} + e_{4,3} {\vec w} + {\bf O}
$

Putting these four equations into matrix form, the vectors and origin of the Cartesian frame $ {\cal F}_C $ can be written in terms of the vectors and origin of the frame $ {\cal F} $ as follows:

$\displaystyle \left[
\begin{array}{c}
<1,0,0> \\
<0,1,0> \\
<0,0,1> \\
(0...
...rray}{c}
{\vec u} \\
{\vec v} \\
{\vec w} \\
{\bf O}
\end{array}\right]
$

And this equation implies that

$\displaystyle \left[
\begin{array}{cccc}
u & v & w & 1
\end{array}\right]
\left...
...rray}{c}
{\vec u} \\
{\vec v} \\
{\vec w} \\
{\bf O}
\end{array}\right]
$

where now the frames on both sides of the equation are identical. If we then equate the coordinates, we have

$\displaystyle \left[
\begin{array}{cccc}
u & v & w & 1
\end{array}\right]
\: = ...
...e_{3,2} & e_{3,3} & 0 \\
e_{4,1} & e_{4,2} & e_{4,3} & 1
\end{array}\right]
$

This is a very nice result, which says that the coordinate change between $ {\cal F} $ and $ {\cal F}_C $ can be represented by a $ 4
\times 4$ matrix.


Calculating the Components of the Matrix

So how do we calculate the matrix

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

We utilize Cramer's Rule, which is a determinant-based procedure that is used to solve systems of equations. The procedure says that if we are given a vector $ {\vec t} $, we know that in the frame $ {\cal F} $, $ {\vec t} $ has coordinates $ (u,v,w)$ - that is, $ {\vec t} = u {\vec u} + v {\vec v} + w
{\vec w} $ for some $ u$, $ v$ and $ w$. Cramer's rule allows us to calculate $ u$, $ v$ and $ w$ directly from the following vector equations: If we define

$\displaystyle D$ $\displaystyle = {\vec u} \cdot ( {\vec v} \times {\vec w} )$    
$\displaystyle D_1$ $\displaystyle = {\vec t} \cdot ( {\vec v} \times {\vec w} )$    
$\displaystyle D_2$ $\displaystyle = {\vec u} \cdot ( {\vec t} \times {\vec w} )$    
$\displaystyle D_3$ $\displaystyle = {\vec u} \cdot ( {\vec v} \times {\vec t} )$    

then

$\displaystyle u$ $\displaystyle = \frac{D_1}{D}$    
$\displaystyle v$ $\displaystyle = \frac{D_2}{D}$    
$\displaystyle w$ $\displaystyle = \frac{D_3}{D}$    

(We note that the $ D$s are really just determinants in three dimensions.)

By substituting specific $ {\vec t} $s into the equations above, we can calculate the components of the conversion matrix for frames. Specifically,

This can be easily implemented on a computer system. The calculations contain nothing more than a few dot products and cross products.

If the arbitrary frame is an orthonormal frame - which is frequently the case - the calculations are even easier and the interested reader should see the section on Cramer's Rule for more information.


Summary

We have developed a method that converts the coordinates of a point in the Cartesian frame to the coordinates of the same point in an arbitrary frame. The conversion is accomplished by a $ 4 \times 4$ matrix whose components can be easily calculated using Cramer's rule.

We note that this transformation is the inverse of the transformation that converts coordinates from an arbitrary Frame to the Cartesian frame.


Return to the Graphics Notes Home Page
Return to the Geometric Modeling Notes Home Page
Return to the UC Davis Visualization and Graphics Group Home Page


This document maintained by Ken Joy

Mail us your comments

All contents copyright (c) 1996, 1997, 1998, 1999
Computer Science Department
University of California, Davis

All rights reserved.


Ken Joy
1999-12-06