Less Weird Quaternions Using Geometric Algebra
probablydance.comFor people trying to understand quaternions, the faster way to intuition is understanding axis-angle first. I think axis-angle is totally intuitive. First pick a direction (some 3d unit vector) and then rotate around that direction by some amount (so some scalar). Then convert those four numbers to quaternions
qx = ax * sin(angle/2)
qy = ay * sin(angle/2)
qz = az * sin(angle/2)
qw = cos(angle/2)
where (ax, ay, az) is the unit direction (ax^2 + ay^ + az^2 = 1) and angle is the amount you want to rotate.http://www.euclideanspace.com/maths/geometry/rotations/conve...
http://www.euclideanspace.com/maths/geometry/rotations/conve...
A couple things to add.
For notation, we would often see the basis vectors named (e_1, e_2, e_3) instead of (x, y, z).
The quaternions are the even-ordered subalgebra of the 3D exterior algebra. The exterior algebra has scalars (1), vectors (x, y, z), bivectors (xy, yz, zx), and pseudoscalars (xyz). The even-ordered subalgebra is scalars and bivectors (1, xy, yz, zx). Adding or multiplying two even-ordered multivectors will always give you an even-ordered multivector, and 1 is even-ordered, so the even-ordered multivectors form a subalgebra.
We can also conceive of this subalgebra, the quaternions, as a Clifford algebra. Clifford algebras are generalizations of exterior algebras. Instead of saying v * v = 0, we can put something else on the RHS, and for quaternions we can start with just two basis vectors e_1 and e_2, and then define e_1 * e_1 = e_2 * e_2 = -1. The third basis vector for quaternions is then just e_1 * e_2.
The odd-ordered subalgebra (x, y, z, xyz) is symmetrical to the even-ordered subalgebra (1, xy, yz, zx), and can also represent quaternions.
The odd-ordered subspace is a subspace, not a subalgebra, because multiplication is not closed.
That doesn't work, the odd space isn't closed.
xx = 1
I don't know what I was thinking....
Quaternions are beautiful and natural, not weird, but I'm always happy when they get some attention! This was a very interesting article, thanks. It does seem to confuse quaternions in general with (unit) quaternions as used for rotating vectors. For example:
>So don’t think of quaternions as a 4 dimensional hypersphere of radius 1
This is also a bit weird:
>But nobody would ever suggest that we should think of a rotation matrix as a 9 dimensional hyper-cube with rounded edges of radius 3.
Even weirder when they claim that the axis-angle interpretation of (unit) quaternions "breaks down".
Anyway, back in high-school when I first became fascinated with quaternions I certainly didn't expect to be working with them on a daily basis two decades later. The moral of this is that anything you learn can become crucial to your career...
While we all learned in middle school geometric algebra that the even subalgebra of G3 is isomorphic to the quaternions, what is the relationship between the even subalgebra of G4 and the octonions?
If you write out a multiplication table, it seems that it's isomorphic. But... Octonions aren't associtive. Does the even subalgebra of G4 somehow lose associativity? Is it equivalent to Octonions with a cannonical multiplication order?
Quarternions aren't weird. With a 2D angle we use 2 numbers (sin and cos) to calculate vector rotations. It turns out that in 3D we use 4 numbers.
There's a lot of hand waving in that phrase, "it turns out". Sure, "it turns out" that 3D uses four numbers. Why?
Geometric algebra explains that in a succinct way that also appeals to our intuition about geometry. Start by using bivectors to represent reflections, then take the closure of your bivectors and you get the even-ordered subalgebra. This will have dimension 2^(N-1)... so 2 for 2D, 4 for 3D, and 8 for 4D.
This, to me, takes the mystery out of why quaternions can represent rotations, and it places quaternions in a coherent theory of geometry that works in any number of dimensions, not just 3D. Alternatively, we could accept that the math just happens to work out that way, or we could even show that quaternions are a double cover of SO(3), but all that does is analyze why something works, whereas the geometric algebra version is a bit less of a leap and builds quaternions from the ground up.
What I meant is that quaternions don't seem any weirder to me than sin/cos.
I think there is a lot of unintentional irony in what you wrote. You start out saying, "There's a lot of hand waving in that phrase..." and then go on to write:
"Start by using bivectors to represent reflections, then take the closure of your bivectors and you get the even-ordered subalgebra."
It reminds me of the running joke we had in graduate school. Any book whose title starts off with "An Elementary Introduction to..." was going to be very difficult.
I aiming that explanation at people who had read and understood the article. The article explains bivectors and how they can be used to represent reflections, and "closure" is a fairly common concept, so once you put those two together you should get a mathematical object which I've called "the even-ordered subalgebra". I haven't explained why it's even-ordered or what a subalgebra is, but I used those terms so you could at least have the vocabulary to talk about it or do a Google search.
Mathematics education is hard. In my experience, you start out with no understanding of a subject and can't understand it when people explain it to you, and at some point it clicks and you can't understand why it was ever difficult. I could be intentionally obtuse and, for example, describe a vector space as an "abelian group, field, and homomorphism from the field to group endomorphisms", but I feel that's the only people who would use that definition already have a good understanding of vector spaces.
The reason that I consider the non-GA approach to quaternions as rotations "hand wavy" is because it's not constructive, or perhaps just because I personally don't understand it. Using GA, I can construct a representation for rotations in any Euclidean space, not just 3D space, but 2D, 4D, 5D, whatever. However, without GA at my disposal, the fact that unit quaternions are a double cover for SO(3) seems like some kind of black magic that came from the void.
I have a few drafts of an introductory article I was writing on geometric algebra sitting on my hard drive, but I've never been able to get the article into a state I'd consider publishable. So instead, I'm trying to inject what I know into HN discussions.
I was a math Ph.D. student at Purdue University and studied commutative algebra. I understand what you were getting at. My comment was mostly tongue in cheek. For someone not versed in mathematics what you wrote could be ironic in a slightly humorous way. I.E. that the hand wavy way explanation is more understandable to a layman than subalgebras, and whatnot. That's the ironic difference between mathematicians and non-mathematicians. What is hand wavy to us is concrete to them and vice versa.
There's definitely something a bit "just a monoid in the category of endofunctors" about that description. Which is not to say that it's not both true and helpful - it's just not very accessible. Perhaps if there was a one-sentence explanation of what a bivector was, it would be a lot clearer.
A scalar is just a magnitude (call it amount). A vector is a direction with magnitude (call it length). A bivector is a pair of directions with magnitude (call it area). You can keep going and make something with volume and even more into higher dimensions.
Imagine putting a 2d rectangle into 3d space with some orientation. Starting from some corner of the rectangle, you have two sides coming out from it. In 3d space, those sides make 3d vectors. You can generalize it to 3 vectors making a cube with magnitude (volume). And these don't have to be perfect rectangles and cubes, they can be parallelograms and parallelopipeds (3d parallelograms) and higher dimensional analogues.
A bivector is a plane spanned by two vectors, with an associated orientation.
That hasn't helped!
Think in terms of magnitude (which can be positive or negative) and direction.
Think of a scalar. It has a magnitude but it doesn't have a direction. It's 0-dimensional.
Think of a vector. It has a magnitude (the size of the vector) and it also has a direction, which points in a straight line through the origin. It's 1-dimensional. For example, the vector (2,0,0) has magnitude 2 and points along the X-axis. You could write that as 2 * x, if x is the vector (1,0,0).
A bivector also has a magnitude, but instead of being 0-dimensional (like a scalar) or 1-dimensional (like a vector, it's 2-dimensional. So you could have a bivector that "points" along the entire XY-plane (remember: two-dimensional) and has some magnitude, say, 5. You could write that as 5 * x * y, if x is (1,0,0) and y is (0,1,0).
If you attach physical units to these things, then you might have units of meters for vectors, and square meters for bivectors.
Having an understanding of subspaces in linear algebra is helpful.
In a geometric setting - if you have two vectors, you can position them so that both have one end at the origin. This spans a plane (test it out yourself in 2D or 3D space with two pencils, put the eraser at the origin for each; it's a parallelogram). The area of the plane will depend on the length of the pencils. You can assign an orientation to the plane by imagining a rotor embedded in the plane that spins either clockwise or counterclockwise.
Hmmm.
"The area of the plane will depend on the length of the pencils". Surely the area of the plane is infinite? The area of the _parallelogram_ will depend on the length of the pencils.
And I can't see how "you can assign an orientation to the plane" other than by changing the directions of the pencils. Again this description sounds like it refers to the parallelogram, not the plane.
And I don't know what a rotor is.
But other than that, I'm doing great.
Yes, when I said plane I really meant the parallelogram. By rotor I literally just meant "a thing that spins" - you could draw a circle on the parallelogram with an embedded arrow describing the direction it is spinning - that arrow could either be going clockwise or counterclockwise.
The length of a line is infinite too. If you think of a vector as a line + magnitude, it's a bit more natural to think of a bivector as a plane + magnitude.
Do you know what a vector is? Vector:Line == Bivector:Plane
A vector is an oriented (+,-) magnitude(length) _in_ a line. A Bivector is an oriented (+,-) magnitude(area) _in_ a plane.
That area does not have any particular shape.
I think that's a good motivation why we would study quaternions, but it's kinda hiding the big difference between 2D and 3D under the rug. In 2D, we have a nice, global coordinate system for the space of all rotations: what we call the angle. (Actually, it's a coordinate system for the "universal cover" of the space of rotations since angle X and angle X + 2pi give the same rotation, which mostly doesn't really matter.) Meanwhile, in 3D, there is no global coordinate system for the space of rotations! Euler examples uniquely specify a rotation, but the problem of Gimbal lock [1] means that they break down as coordinates at some point (i.e. there's no inverse to go from rotation in 3D to its corresponding Euler angles, which there is in 2D, with the caveat already mentioned).
This is analogous to the problem of finding a coordinate system for the globe: specifying latitude and longitude tells you were you are, but there's a degeneracy at the poles. And no possible coordinate system can solve this problem entirely. Contrast this to the situation of giving a coordinate system for the circle, which we do with it's angle. This isn't quite a coordinate system, due to the problem we already encountered that X and X + 2pi are the same, but that's OK because the these two points are separated from each other. On the sphere, the latitude/longitude pair (pi/2, x) gives the north pole for any value of x, even ones that are arbitrarily close together. That maps not even locally invertible!
You suggest we think of points on the circle as point in 2D space that happen to lie on the circle (i.e. cos and sin of the angle corresponding to that point). Analogously, we can think of points on the sphere as points in 3D space that happen to lie on the sphere (like some point (x,y,z) with x^2 + y^2 + z^2 = 1). And analogously, we can think of rotations of 3D space as a point in 4D space (that happens to satisfy some conditions), and the quaternions give that 4D point. This is fantastic and convenient in both 2D and 3D! But in 2D we didn't need to do this, but could if we wanted to. For 3D rotations, we do need to, or else we have this terrible degeneracy that never rears its head in 2D. In that sense, 2D and 3D are very different!
> Meanwhile, in 3D, there is no global coordinate system for the space of rotations
There are plenty, it's just that you can't have a 3-dimensional one without singularities.
The term "coordinate system" isn't well-defined without context. I was taking non-singular implicitly as part of that - actually, not so implicit since that's sort of the point of the digression. Of course, other contexts are happy to say that, say, polar coordinates are a coordinate system even including the singular point at radius 0, so I probably should have been more careful and said a "coordinate chart."
This helped me a lot to understand quaternions using simple algebra: https://math.stackexchange.com/questions/147166/does-my-defi...
This is great insight, but it seems a bit silly to act like you don't need a 4D / hypersphere representation when the 4th one is hiding in plain sight. For the not-quaternion to describe a rotation, it needs unit length in 4D, with the two components scaled as a sine/cosine pair.
Geometric algebra is "easier" to understand than plain-old imaginary numbers? Pourquoi?
> OK so what is this Geometric Algebra? It’s an alternative to linear algebra.
No. Geometric algebra is a use case of linear algebra. How can it be an alternative?
> Before I tell you how to actually evaluate the wedge product, I first have to tell you the properties that it has:
> 1. It’s anti-commutative: a \wedge b = -b \wedge a
> 2. The wedge product of a vector with itself is 0: a \wedge a = 0
Redundant information. The latter follows from the former.
It's definitely an alternative in the sense that it gives you an alternative framework for concepts that are taught under the banner of linear algebra in school. For example, it gives an alternative construction for quaternions as a subalgebra, and it gives the exterior product as an alternative to the cross product.
I'd say alternative is an unlucky choice of words. I'd rather say geometric algebra (GA) is an extension of linear algebra (LA). In order to really understand GA you need first to firmly understand LA. Then it becomes clear that all that GA does is to turn a Hilbert space into an algebra called a Clifford algebra, and to examine the geometric semantics of the various operations that pop up in the process.
Here are three great sources that helped me to understand GA:
1. https://www.amazon.co.uk/Geometric-Algebra-Computer-Science-...
2. https://www.amazon.co.uk/Linear-Geometric-Algebra-Alan-Macdo...
3. https://www.amazon.co.uk/Algebra-Graduate-Texts-Mathematics-... , pages 749-752
The first source gives great motivation and intuition for GA and its various products. Its mostly coordinate free approach is very refreshing and makes the subject feel exciting and magical. This is also the problem of the book, it's easy to end up confused and disoriented after working through it for a while. The second source is great because it grounds GA firmly on LA, and makes everything very clear and precise. The third source gives a short and concise definition of what a Clifford algebra is.
My personal recommendation for a book on geometric algebra is the one by Hestenes, New Foundations for Classical Mechanics (https://www.amazon.com/dp/0792355148/). I was disappointed by Geometric Algebra for Computer Science and I recently got rid of my copy when I moved to a new apartment, but I have a mathematics background and tend to prefer denser books.
I would say that "alternative" is a viable word here. Yes, you'll need a foundation in linear algebra to understand geometric algebra, but our classes and books on linear algebra go beyond what is necessary for understanding geometric algebra and introduce concepts (like the cross product) which have more natural equivalents in geometric algebra. I'm not even convinced that it's necessary to have a good understanding of matrixes in order to work with geometric algebra.
I guess we have to agree to disagree. GA is not an alternative to LA, as LA is the foundation of GA.
The main point of LA is not matrices, but linear operators, dimensionality, linear independence, bases, etc. Matrices flow naturally from that. If all you have been taught in LA is to manipulate matrices, then I can see why you feel about the relationship between LA and GA the way you do.
You're saying things that I agree with 100% which makes me think that there's something missing from my explanation.
I'm not talking about linear algebra as a field of mathematics in some kind of ideal sense here. Yes, obviously, it's a foundation for geometric algebra. You don't need to convince me of that.
However, elementary linear algebra classes don't teach you about linear operators, they teach you about things like matrixes and cross products. In these basic classes, a "vector" is a "thing with X, Y, and Z coordinates". So when you get to physics, you use the cross product to write a formula for magnetic field. You have to remember that the magnetic field is transformed differently from other vectors according to some special rules. And engineers call this stuff "linear algebra". Mathematicians agree that it's linear algebra, but we know that there's a lot more to linear algebra that goes beyond that.
Alternatively, they could calculate the magnetic field using geometric algebra, and express it as a bivector, at which point all of those special rules vanish.
That's why Hestenes's book is called "New Foundations for Classical Mechanics". It's not that linear algebra is not the foundation for geometric algebra. It's that classes taught in colleges which are called "linear algebra" teach you the concepts used by Gibbs and Wilson in the book Vector Analysis, and these concepts don't generalize to different numbers of dimensions. GA does. Maybe the problem here is that we don't have a special name for that field of study which uses cross products, if had a different name for that stuff, say "vector analysis" after the book first appeared in, we wouldn't have a problems saying that "geometric algebra is an alternative to vector analysis".
GA is a nice alternative to the stuff they teach engineers scientists under the "linear algebra" banner.
Another example… look at Stokes' Theorem. The version with differential forms is a nice alternative to the version with just a cross product.
No, it's not an alternative. You're conflating the grab bag of topics in an undergraduate linear algebra class with the subject of linear algebra.
Linear algebra is the study of linear operators on vector spaces over fields (a special case of modules over rings). Some vector spaces are inner product spaces, but most are not.
Exterior algebra is an example of multilinear algebra. Clifford (or geometric) algebras are constructed as an algebra over a vector space. Quaternions come via a different route: instead of constructing a multilinear algebra, they are one of a handful of very special algebras like C and the octonions.
Exterior algebras themselves are defined in terms of standard linear algebra concepts (tensor algebras, ideals, quotients). I don't see how you can claim something is an alternative to linear algebra if you need to know linear algebra to define it, nevermind use it.
Left is an alternative to right. Right is the opposite of left. They are alternatives, yet defined in terms of each other. You can't know one without the other.
Doesn't seem contradictory to me...
> Redundant information. The latter follows from the former.
It's a blog post, not a paper. If I give you a brand new operator ^ that takes an arbitrary object a and another object b and tell you that it has anti-commutativity, it's not a given that a ^ a = 0. So it's useful to highlight that this IS the case when a and b are the vectors of GA, for intuition's sake. a = -a iff a is the zero vector. What if our objects are rotations or something though? R = -R does not imply R = the zero rotation.
^ is the multiplication operator of an algebra, though.