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 conversion matrix. The general n-dimensional case is then discussed. We conclude with a discussion of how to generate this conversion matrix.
For a pdf version of these notes look here.
Examples of Frames
Two-dimensional examples of frames are fairly straightforward to produce. We will denote the frames as .
In fact, we can define a Cartesian frame for any dimension. It consists of the origin , and the vectors , , ..., . This is the frame that we normally refer to when discussing points in multiple dimensions.
Points and vectors can be uniquely identified by the coordinates relative to a specific frame. Given a frame in an affine space , we can write a point uniquely as
Thus, points are represented as row vectors whose last component is and vectors are represented as row vectors whose last component is 0 (zero).
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 and where
Suppose we have the point , with coordinates in the frame . What are the coordinates of the point in the frame ?
This is straightforward to calculate using the matrix notation for the points.
Now carefully note what we did in this calculation. First we wrote the point in the matrix notation for the frame . 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 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 matrix and the column vector representing the second frame. We then multiplied the matrix times the initial coordinate to obtain the result.
This can be done with any coordinate from the first frame, as the matrix generated will be the same in every case. That is, given a coordinate from the first frame, we can convert it to a coordinate for the second frame by simply calculating
To convert coordinates from one frame to another in -dimensional space proceeds in the same way as the example above.
Suppose a point has coordinates relative to some frame . What would be the coordinates of relative to another frame ?
Well since is a basis, we can write each of the vectors uniquely in terms of the . In addition, since is a vector, we can also write uniquely in terms of the and . Thus we can calculate coefficients defined by
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 relative to the new frame .
We also note that if we consider the frames in three dimensional space (i.e. ), the matrix is .
So how do we calculate the matrix
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 and and the matrix will be
Given any frame , and a vector , I know that for some , and . Utilizing Cramer's Rule, I can calculate these coordinates directly by the following process: If we define
Utilizing this process, we can let , and we can let and calculate , and ; we can let and calculate , and ; we can let and calculate , and finally we can let and calculate , and .
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.