Are 4x4 matrices useful in 3D only because of translation?

594 Views Asked by At

Having interest in 3D computer graphics, I've stumbled upon four dimensional matrices.

After a bit of research, I've found out that this was a trick to represent translations, but no more than a trick, which doesn't seem very satisfaying, because of the fourth components of any vector always being one.

Is there any other more fundamental reason for the use of a 4D matrix in 3D?

I'm not asking particularly in the context of computer graphics since this is a math forum.

2

There are 2 best solutions below

6
On

Usually you will only need $3 \times §$ matrices in 3D, as they represent linear maps; although using them to describe translations is a neat trick. However, there is also another essentially four-dimensional object that is used to describe 3D-Rotations (apart from orthogonal matrices): The quaternions.

Just as the complex numbers are an extension of the real numbers by an element $i$ fulfilling $i^2=-1$, one can also add two more elements $j^2 = -1$ and $k^2=-1$, fulfilling identities like $ij=-ji=k$ etc. A general quaternion will then have the form $a+bi+cj+dk$; therefore, they form a four-dimensional vector space.

By a lucky coincidence, the set of unit quaterions, i.e. quaternions with $a^2+b^2+c^2+d^2=1$ (which obviously just forms a sphere in 4D-space), with their obvious multiplication (linear over the real numbers), represent the rotations in 3D space, i.e. every unit quaternion can be assigned a rotation, and every rotation can be assigned a quaternion (actually two, since the negative of a quaternion describes the same rotation, but that is a bit more technical). Since I don't know your mathematical backgrounds, I am not quite comportable refering to some further literature for you to read, but as it is quite broad I am sure you'll find something that fits you. Of course, you can also come here with further questions. Greetings,

Markus Zetto

3
On

The fourth component (the way it's usually done) lets you distinguish between vectors that are positions and vectors that are displacements (like distances and velocities) completely naturally, and without having to have separate classes by just inspecting whether the final element is $0$ or $1$. And if you add together vectors so that the final component becomes something other than $0$ or $1$, then you know some of those vectors don't belong in that sum.

Don't underestimate the power of making translations into linear operations together with rotations and scalings. It is more than just a trick, it really makes much of the programming a lot easier, especially when it comes do doing several transformations in succession.

This makes it so that displacements are affected by any rotations and scalings you might do to your world, as they should, but not affected by translations, which is a good thing (the coordinates of a displacement between two positions should be the same after translating everything by the same amount, after all). And again, this happens automagically, without you having to program in logic to detect whether the operation is a translation and whether the vector is a displacement, it's just a consequence of matrix multiplication and having that fourth component be either $0$ or $1$.

Finally (at least for what i can think of on the fly), it allows you to have things "infinitely far away", like a skybox, by giving them positions with $0$ as final component, making those also "immune" to the translation operations (somewhat ruining the first point about distinguishing the two types of vectors, but still).