![]() |
Home | ![]() |
About Me | ![]() |
Notes | ![]() |
Galleries | ![]() |
Files | ![]() |
Links | ![]() |
![]() |
Programming | ![]() |
Maths | ![]() |
Odd Bits | ![]() |
![]() |
Vectors | ![]() |
![]() |
Primitives | ![]() |
Operations | ![]() |
Matrix Operations | ![]() |
Homogeneous Matrices | ![]() |
Earlier it was mentioned that translation using matrix multiplication is impossible since translation affects all points in space but matrix multiplication can't transform a vector made of zeros into one that isn't also full of zeros, i.e. the origin is invariant under matrix multiplication.
This limitation would seem to spoil the most useful feature of matrix multiplication, the ability to composite several transformations, including translation into a single matrix.
But wait, There's a trick! All we have to do is move the origin to somewhere where no one will ever find it: In another dimension!
The trick is demonsrtated here for 2D graphics. It's trivial to extend the principle to 3D graphics.
![]() A house drawn in 2D plane |
This figure exists in a 2D plane. Vertices in this plane are written in the form
|
|||||||||||||||||||||||||||||||||||||||||
![]() Set the plane in a 3D space |
Add an extra axis, w and set the original 2D plane at
w = 0. The original vertices are now written as
|
|||||||||||||||||||||||||||||||||||||||||
![]() Move the 2D plane 1 unit away from the 3D origin |
Move the 2D plane to w = 1. The original vertices are now
written as
|
|||||||||||||||||||||||||||||||||||||||||
![]() This shear transformation translates the 2D plane ![]() The house, translated |
Let's demonstrate a simple translation of
A neat feature of the homogeneous system like this is that a vertex, which has a position but no size or direction is written with a non-zero w, and a vector, which has a size and direction but cannot have a position let alone be translated, is written with a zero for w. Normals and the direction of infinitely distant light sources are examples of such vectors. They are unaffected by the translation component of homogeneous transformation matrices. |
|||||||||||||||||||||||||||||||||||||||||
The principle of homogeneous coordinates and matrices works equally well with one, two, three or any number of dimensions. All it takes its another dimension.
It might seem that tacking on extra 1s to vectors and multiplying by larger matrices may seem a computational hassle, even if homogeneous matrices do allow the composition of arbitrary numbers of transformations, including translation, If you only plan to perform basic transformations in the w = 1 plane, then you can use Affine matrices. Just chop out all the 0s and 1s and define a kind of matrix multiplication that works with the 2 × 3 matrices that remain. In other words, don't store those 0s and 1s and don't do arithmetic with them.
This concludes my notes on vector algebra. You should be able to write a killer 3D app now, or at least get some sleep.