6
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ You can represent a much larger class of transformations than the affine transformations by using $4\times4$ homogeneous matrices. See this question and the answer to it. You might also want to read up on homogeneous coordinates for other ways in which they are useful. $\endgroup$
    – amd
    Apr 26, 2020 at 21:49
  • $\begingroup$ You might be interested by this answer explaining how interesting are $4 \times 4$ matrices in connection with geometrical issues. $\endgroup$
    – Jean Marie
    Apr 27, 2020 at 9:56

2 Answers 2

3
$\begingroup$

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).

$\endgroup$
3
  • $\begingroup$ Oh, I see! By the way, what would be the point of letting that fourth components being some where between 0 and 1? What would it mean to translate a vector, but only partially? Would it have something to do with translation in screen space after a perspective projection? $\endgroup$ Apr 26, 2020 at 11:56
  • $\begingroup$ @JonasDaverio No point that I see. Positions have final component $1$, displacements have final component $0$, and there is nothing else. In 2D graphics, you can do three components the same way, and if you give the background a third component of $0.5$, or the foreground a third component of $2$, it will parallax shift as the camera moves. But I don't know how the corresponding 3D graphics concepts would make any sort of real-world sense. Could be cool and trippy, though. $\endgroup$
    – Arthur
    Apr 26, 2020 at 12:10
  • $\begingroup$ @JonasDaverio Back in the old days when floating-point arithmetic was really expensive, you could use the “extra” coordinate as a scale factor (denominator) and do all the calculations with integer operations on what were effectively rational numbers. The “extra” component is still used to implement z-buffering. $\endgroup$
    – amd
    Apr 26, 2020 at 21:53
1
$\begingroup$

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

$\endgroup$
6
  • $\begingroup$ I never really felt comfortable with quaternions because how they are defined seems pretty arbitrary in commonly given explanation. What I heard is that quaternions can be far better understood with tensor algebra, but I didn't find some relatively easy to read source that explained the link. I have a tiny bit of insight with tensors, mainly from my attempt to selfteach general relativity, so I think I could at least get a little bit of insight with a source if you have one. $\endgroup$ Apr 26, 2020 at 11:53
  • $\begingroup$ By the way, why do rotations have to be represent with 4 components? There are only three degrees of freedom, we could represent them with an axis of rotation plus a magnitude for the angle of rotation, which could be package in just three numbers. $\endgroup$ Apr 26, 2020 at 11:55
  • $\begingroup$ Yes it is true, rotations can be captured in only 3 numbers: Either the Euler angles or, as you said, axis and magnitude. However, these do not form a linear object like a vector space or something like that, but a Lie group, a group that is also a manifold. However, to deal with them efficiently, it is convenient to embed them into a linear space. The usual one would be the set of $3 \times 3$-matrices, which is 9-dimensional, but the quaternions have the advantage of being smaller, while still capturing the nonabelian group stucture. $\endgroup$ Apr 26, 2020 at 12:39
  • $\begingroup$ The reason why quaternions are so important (and not at all arbitrary, just some of the used conventions are) is that together with real, complex numbers and octonions, they are the only normed division algebras over the real numbers. This is why they often occur when classifying things in differential geometry, like compact Lie groups. If you want to see an approach using tensor algebra, you will need to get familiar with exterior and Clifford algebras, see empg.maths.ed.ac.uk/Activities/Spin/SpinNotes.pdf for a good introduction. $\endgroup$ Apr 26, 2020 at 12:45
  • $\begingroup$ However, there is very little literature on quaternions for their own sake; articles by John Baez however are always very pedagogic and helpful in this context. $\endgroup$ Apr 26, 2020 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .