24 ms·
Let's remove quaternions from every 3D engine (2018)
- Epskampie 7y agoPrevious discussion: https://news.ycombinator.com/item?id=18365433 https://news.ycombinator.com/item?id=18365433
- ColinWright 7y agoI've only skimmed the article, but it seems to be saying this: > Instead of using this thing you don't understand and investing the time to understand it, why don't you use this other thing you don't understand, and invest the time to learn that instead. Indeed, later in the article the author says: > We can notice that 3D Rotors look a lot like Quaternions ... In fact the code/math is basically the same! The main difference is that i, j, and k get replaced by y∧z, x∧z and x∧y, but they work mostly the same way. Have I got that right?
- ianai 7y agoThat’s a notational change that incurs unneeded, increased cognitive load. That’s admittedly a mile high view.
- mcnamaratw 7y agoSure, people who are happy customers of quaternions and don't feel driven to understand what's under the hood, why change? The pitch in the OP is (I think) intended for people who feel pressure to understand why it works. Geometric algebra can be built up yourself by picturing actual rotations, one dimension at a time. It's physical from the start. Quaternions are a finished math system that you have to reverse-engineer to understand. Some people like one approach or the other better. Some geometric algebra people are kind of true believers. That's probably not helping the notation get traction.
- friendlybus 7y agoIt's possible to plot the rotation of planets around the earth using very complex systems. Why didn't we stay with that? Why not change? Comfort?
- mcnamaratw 7y agoWhy not change? It's a good question. Learning about GA is an investment, getting it coded up and tested is an investment, and the obscurity of GA is going to make the code almost encrypted to people who aren't fairly mathy. Although quaternions are definitely crazier than GA, the sad fact is they're much more popular. There's some return on all that investment. It might pay off or it might not. I think it's a design decision.
- Certhas 7y agoThat's not correct. Mathematically as they describe the same thing they have to be translatable into each other. But one is a natural mathematical definition, the other exploits a completely unintuitive incidental mathematical isomorphism. If you would read a few sentences on from where you quote, this becomes evident. ij = k is arbitrary, needs to be memorized and just happens to do what you want for reasons that require a lot of working out. (xy)(yz)=x(yy)z=xz On the other hand requires zero memorization.
- ColinWright 7y ago> ij = k is arbitrary, ... It's probably my mathematical background speaking, but I find this far from arbitrary. Quaternions don't spring from nothing. It seems to me that (xy)(yz)=x(yy)z=xz needs just as much justification and memorisation ... why should y^2=1? I guess my point is this. If people put in as much effort to understand quaternions as has been expended in this article, then quaternions would probably be just as easy to grasp and the system being described.
- bonzini 7y agoBut they wouldn't extend to 4D. You can treat complex numbers as 2D rotors (a 2D rotor is cos alpha + xy sin alpha, so xy can be replaced with i) and quaternions as 3D rotors. But if you build Cayley numbers from quaternions they don't have the same geometric meaning as 4D rotors.
- wbhart 7y agoy^2 = 1 because it is the sum of the dot product (1) and the outer product (0). The latter is because the parallelogram between y and y has zero area. The former is just the length of the vector y. Some memorisation is required, but it is in terms of things that are easily visualised.
- bonzini 7y agoBut why would the area be expressed as a length? This always struck me as a coincidence, and having read on bivectors it just makes sense that it would be (because a vector represents a distance on a line, a bivector represents an area on plane, a trivector represents a volume on a 3D space and so on).
- zupatol 7y agoI haven't read that particular article, but from other sources I've read quaternions appear to be mysterious/magical even to people who know them, while the rotors have a very concrete geometrical interpretation in geometric algebra. Geometric algebra also addresses much more than just rotating stuff, it's just that when you want to do rotations it leads naturally to something very similar to quaternions.
- xg15 7y agoYour opinionated summary implies that both concepts are equally hard to understand, but the whole point of the author is that rotors are potentially a lot easier to understand and reason about than quaternions. He also gives a concrete reason: For 3D objects, rotors operate fully in 3D, whereas quaternions are in 4D. This means you can visualize rotors and imagine "how they work" whereas with quaternions, you have to more or less blindly trust the formulas.
- ptero 7y ago> rotors operate fully in 3D, whereas quaternions are in 4D. This means you can visualize rotors ... whereas with quaternions, you have to ... trust the formulas. This is a bit of a stretch -- by the same logic any operation on more than three numbers means I have to trust the formulas. We have many methods to understand, visualize, develop intuition, etc. in such cases, such as "fix a, look at what happens when you vary b, c and d". When I am working to understand dynamics of an object with three variables in MATLAB or similar, I seldom (probably never) plot it in 3D (which gets projected on the surface of a flat monitor anyway). Instead I usually play with numerous 2D and even 1D plots. My 2c.
- mlatu 7y ago> rotors operate fully in 3D By this, the author means: you can visualize a rotor FULLY in 3D, no extra dimension neccessary. I suspect you never have tried to think about how quaternions work mechanically, I suggest this neat video: https://www.youtube.com/watch?v=d4EgbgTm0Bg https://www.youtube.com/watch?v=d4EgbgTm0Bg
- ptero 7y agoThank you for the link, very cool video! I do get the theory part -- I know how quaternions and rotors work (and have a PhD in "pure" math). My objection (and a pretty firm one) is with the "if a phenomenon has more than three variables we cannot visualize it" logic. While lower dimensions make things a little easier to understand and develop an intuition for, a convenient abstraction or a model is much more important. Most engineers work with things described by multiple variables all the time and "reduce dimension to three" is seldom the main goal. If the claim is that rotor is a better model, more convenient for software engineering, we can examine (and debate) that. But we should not recommend switching just because it has one less variable. For someone with an algebraic rather than geometric view, the ability to multiply quaternions on a piece of paper may be a strong benefit. Double-checking, say the result (1+i)*(j-k) by hand takes 10 seconds and a piece of paper; try mentally computing the rotor composition -- you would probably fall back on algebra (I certainly would).
- onedognight 7y agoYes, you have that right. The underlying operations are the same. What you are missing is that the ideas from geometric algebra work in any dimension! Quaternions are a “trick” that only works in 3D. You can write down Maxwell’s equations using the geometric algebra easily, and it will make them better! They will be obviously coordinate independent. Pretty much anything with a cross product will be better written using geometric algebra.
- solinent 7y agoThe exterior/wedge product is actually very closely related to the cross product, and works to generalize the cross product to n dimensions. You can read Spivak or Munkres, "Calculus on Manifolds" and "Analysis on Manifolds" respectively. One of their main uses is to prove the generalized Stokes theorem in n dimensions. 3D rotors are isomorphic to quaternions, so go ahead and rename your variables :).
- msla 7y ago> The exterior/wedge product is actually very closely related to the cross product, and works to generalize the cross product to n dimensions. So, to be as opinionated as the g'parent comment: The cross product is a hack which only works in certain dimensionalities, whereas the wedge product is the underlying idea, which works in all circumstances. To be less opinionated: The cross product is inconvenient because what it gives you aren't the "usual" vectors, they're axial vectors, which behave differently under mirror reflection than all of your other vectors do.
- solinent 7y agoThis is incorrect, if you read Spivak, you can define and (n-1)-ary product which generalizes the cross product. You give it (n-1) vectors and it gives you a vector orthogonal to all of them. Whether you call it the cross product or not is just semantics, but it does exist in terms of the exterior product. It's difficult to find online, but it's constructed directly in Spivak. A quote: "It is uncommon in mathematics to have a "product" that depends on more than two factors. In the case of two vectors v,w in R^3, we obtain a more conventional looking product, v X w in R^3. For this reason it is sometimes maintained that the cross product. can be defined only on R^3" - Calculus on Manifolds, pg.84 Most graduate students read this (or did five years ago).
- LanceH 7y agoThe best 3d location/vector method I've used allowed rotations using normal x,y,z coordinates, but you could do rotate an object in the xyz of the engine itself, the object, or the object that object was currently attached to. This made things like shooting a lob from a forward facing gun easy, since you could raise the shot from the gun rather than the world and no quaternions were involved. I don't know if quaternions were used underneath.
- gugagore 7y agoI don't understand what you mean, but I think you're describing exponential coordinates, or said another way, choosing an angular velocity and getting a rotation by following that angular velocity for a unit of time. https://en.m.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions https://en.m.wikipedia.org/wiki/Rotation_formalisms_in_three...
- moron4hire 7y agoYou don't need to understand the root construction of Quaternions to use them in game code anymore than you need to understand the root construction of the Reals to be able to do arithmetic in game code. Just treat them as opaque values that have certain operations you can perform to get certain results and be done with it.
- xg15 7y agoThe author is arguing against this exact mentality - and I believe, this was one of the main motivations this article was written: > Personally, I have always found it important to actually understand the things I am using. I remember learning about Cross Products and Quaternions and being confused about why they worked this way, but nobody talked about it. Later on I learned about Geometric Algebra and suddenly I could see that the questions I had were legitimate, and everything became so much clearer. I tend to agree with the author. I find it a lot harder to work with concepts I don't understand: I'm forced to "fly blind" and just plug in formulas and hope everything works. At the latest when you have to debug something, this can go horribly wrong and leave you without a lot of options.
- moron4hire 7y agoSo you know exactly how everything in your computer works, because otherwise it'd be too hard to use? I wager the exact opposite is the case: it's much easier to use a computer through heuristics of operation rather than any sense of "deep" understanding. Besides, your GPU shader code implements fast quaternions, and you aren't going to get NVidia to replace them with rotors. So the game is lost. Oh, unless you don't mean "understand everything" and are going to draw your arbitrary line at the GPU.
- baq 7y agothe math is the same so technically nvidia gpus already implement rotors.
- gugagore 7y agoThey didn't say "understand everything", but that's the interpretation you're replying to, and it gives me some thoughts. Different people will be okay with different levels of understanding. You put "deep" in quotes. You should also put "heuristic" and "easier", and many more, because all of these terms are up for analysis now. A very heuristic operation of technology is "power cycling"--"have you tried turning it off and on". Another version is "factory resetting". This is very useful, but without a slightly deeper understanding of what is does, or how computers work, it's easy to waste time doing it. Like if I get a cloudflare message saying some website is unavailable, I'm not going to log out and back in. I'm not going to turn my computer off. I'm not going to do anything. But that requires a slightly deep understanding. I wouldn't try to argue what's easier and what's harder for people so generally. There are lots of different kinds of people. That's why both the quote and the grandparent are explaining their personal motivations and describing themselves. I mean, you kind of acknowledge this after the fact when you talk about "arbitrary lines", but it still sounds like you're dissing someone's "arbitrary" personality. I mean, yeah, even if it were arbitrary drawn at GPU---that's the sense in which we are individual people...
- stared 7y agoQuaternions are 3D rotations (plus, possibly, rescaling). The author notes that they have the same API (I like this term used in mathematical context). So, the actual point is that the word quaternions (and "these strange i, j, k") is confusing. Rightfully (at least for anyone without a background in maths or physics). "Let's remove Quaternions from every 3D Engine" -> "Let's remove the word 'quaternion' from every 3D Engine" (Nice explanations and visualization, anyway!)
- BlueTemplar 7y agoAPI stands for Application Programming Interface. What is exactly an "API"? Why not just "interface" ? (One should generally avoid acronyms...)
- paulddraper 7y agoYes, it should be interface. No need to distinguish here between API/CLI/GUI.
- cuspycode 7y agoI agree, it's mostly a matter of words. But just for the record, quaternions in general are 4D isoclinic rotations (with optional scaling). Left-multiplication by a unit quaternion corresponds to a left-isoclinic rotation, and right-multiplication corresponds to a right-isoclinic one. By combining them you can produce any 4D rotation. A subset of this is the set of 3D rotations that rotate ix+jy+kz into ix'+jy'+kz'.
- adamnemecek 7y agoCheck out http://bivector.net http://bivector.net, a new community on geometric algebra. Check out the demo https://observablehq.com/@enkimute/animated-orbits https://observablehq.com/@enkimute/animated-orbits Join the discord https://discord.gg/vGY6pPk https://discord.gg/vGY6pPk
- yantrams 7y agoNever heard of this before. Thanks for the share.
- graphpapa 7y agoThis seems to be an excellent introduction to geometric algebra, a topic I have had difficulty picking up so far.
- K0SM0S 7y agoI suggest you look at Mathoma's videos¹ on the topic on YouTube. His explaining is so simple (even too simple, some would say) that GA becomes a no-brainer. The magic really happens with this teacher (for me). A lot like Khan, for comparison. [1]: https://www.youtube.com/playlist?list=PLpzmRsG7u_gqaTo_vEseQ7U8KFvtiJY4K https://www.youtube.com/playlist?list=PLpzmRsG7u_gqaTo_vEseQ...
- yiyus 7y agoAs someone who has to teach GA, may I ask what you tried and what you found difficult? I see problems with the non-standard notation, for example. I also think that it is much easier to understand 3D-GA starting with 2D or even 1D, and of course using a non-formal approach (as we do with vectors). It is also hard to find nice examples between the very obvious and very difficult stuff.
- graphpapa 7y agoI think it is mainly the extra time spent on the foundational definitions - ie. multiple paragraphs and multiple interactive widgets just to clarify what is meant by a bi-vector. I don’t claim to have delved very deep in the topic before, but of course it is standard to start with definitions - and I found these definitions particularly clear & disambiguated.
- duke360 7y agoquaternions (<3) are extremely useful and not so hard to learn as other have pointed out. it's just a matter of lazyness and intesrest in solving a problem
- wccrawford 7y agoLearning to use Quaternions is easy. Learning how they work is much, much harder. Likewise, IMO, learning to use Rotors is easy, but learning how they work is much harder... It's just that it's easier than learning how Quaternions work. And, also IMO, you don't need to know how either of them work to use them in gamedev. It's fine to use a library that understands them and just continue making the important parts of your game.
- K0SM0S 7y ago> “It's fine to use a library that understands them and just continue making the important parts of your game.” Oh that's indeed absolutely what a game dev should do. A 3D engine dev however, might do well to eat the math leading to the understanding of quaternions, and by extension Clifford algebras (the underlying/original theoretical structure leading to geometric algebra). You get to understand how particular variations in n-dimensions of this structural framework are isomorphic to all numbers like R, C, H and much more. (hyperbolic! dual!) It really paints a whole arch-picture, a meta-framework to unify all possibly kinds of numbers in one's mind (including the geometry of these numbers and ring operations, with a 1:1 equivalence between geom and algebra). Note that this is why, I think, some strong proponents of GA (which I find myself agreeing with in that regard) would have it enshrined in K-12 education in lieu of linear algebra — because the intuition of GA is really great / second-to-none, and intuition is all that most math students in high school will ever retain afterwards (they won't do math again, ever, not really). The argument being that people who need more (from linear algebra for calculations notably) can learn that complicated and non-intuitive stuff later (university), building on top of a good base intuition nurtured in GA / Clifford. So, the 3D engine maker, people in robotics, anyone working with spatial representations of any kind (even abstract, like research with multilinear models) would do themselves a fantastic favor for a lifetime to learn these topics. It's a no-brainer, really, from the other side. It's delicious math!
- pauljurczak 7y agoIn order to make geometric algebra really nice, you have to go 5D, see versor.mat.ucsb.edu. This imposes a significant computational overhead. Nice things are expensive.
- gugagore 7y agoI think that's a different point. To get rotations in 3D you don't need to go to 5D conformal GA. To be able to unify many geometric objects, like lines and spheres and point pairs and represent the duality e.g. the "meet" of two lines constructs a point (possibly a point at infinity) and the "join" of two points constructs a line (not sure what happens if the two points are identical), .... then you need 5D which is really like 2^5 = 32D in my mind. But if all you're trying to do is stop being confused by two different things that both look like vectors, but transform differently under spatial transformations (i.e. any vector that is the result of the cross-product is really a different type of vector than the argument vectors, or e.g. normal vectors) then 3D GA is fine. Though really it's more like 2^3 = 8D (1 scalar, 3 regular basis vectors, 3 "axial" basis vectors, and one pseudo scalar). An efficient implementation would likely need to use a type system avoid representing 8 dimensions directly. Like the cross product of two vectors will produce an element where only the "axial" components are non-zero.
- pauljurczak 7y agoYou are right, 5D conformal GA goes way beyond nice rotations in 3D space, but why stop there? We can have two worlds: computationally expensive, high level, powerful abstractions and computationally efficient, messy abstractions. In some cases of rotation, even quaternions are too much.
- pflats 7y agoI'm a pure math dude at heart, even if I don't get to do it much any more. Two years ago, my wife asked me, "If you had to get a math equation tattooed on your body, what would it be?" I answered, "i^2 = j^2 = k^2 = ijk = -1". I felt a brief flush of anger when I saw this headline. This is an extraordinarily good article that should be read by pretty much anyone doing graphics programming.
- s_dev 7y agohttps://en.wikipedia.org/wiki/Broom_Bridge https://en.wikipedia.org/wiki/Broom_Bridge You're like this Irish bridge that has the notation inscribed on it as well. I would like to own an OpenGL kettle with the expression on it.
- andybak 7y ago> I would like to own an OpenGL kettle Do you mean the Utah Teapot?
- s_dev 7y agoYes -- I don't even know why I had the word kettle in my head.
- war1025 7y agoI knew what you meant and didn't even consider that it was the wrong name, for what it's worth. Kettle and teapot are synonyms as far as I'm concerned.
- jfengel 7y agoKettles go on the stove (or have a built in heater), and are used for boiling water. You pour the boiling water into a teapot, usually made of ceramic, which holds the tea leaves. Not that it's important, but now ya know.
- 7y ago
- martin-adams 7y agoI have no experience in this area. Would making a change like this inside a 3D Engine have any impact on performance?
- CrazyStat 7y agoNo, they're mathematically exactly the same. Just a different way of thinking about the same mathematics that the author argues (probably correctly) makes more intuitive sense.
- bordercases 7y agoThe development environment would have to be set up such that the part of the language that uses GA primitives could be efficiently transpiled into their corresponding matrix abstractions to prevent loss of performance on the GPU at runtime.
- earenndil 7y agoIt's unclear that you really need to convert to matrices before sending off to the GPU. [1] finds that quaternions are faster; I find that questionable (does it scale?), but it shows that the two are comparable. 1: https://tech.metail.com/performance-quaternions-gpu/ https://tech.metail.com/performance-quaternions-gpu/
- mcphage 7y agoI'm confused—the author keeps referring to rotations. The very first sentence is "To represent 3D rotations graphics programmers use Quaternions", even. But I don't think you don't need quaternions to represent 3D rotations. You need quaternions to represent translations, because translations aren't linear functions in 3D. (To be a linear function, v * 0 = 0, but that isn't true for translations). My understanding was that the extra dimension was to be able to represent translations. Am I mistaken?
- heyitsguay 7y agoYou don't need to restrict yourself to mathematically-nice algebras of operations or whatever if you're doing 3d graphics though. If you want to represent a translation of x by vector v in 3D, just do x+v.
- mcphage 7y agoWell, linear functions have the nice ability to be composed together, resulting in another linear function (which can then be composed, etc).
- heyitsguay 7y agoComputable functions have that same property, and that's the space that programs work in. It doesn't matter if the composition elements are linear, only that they can be computed on your hardware within some time budget.
- matt-noonan 7y agoYes, you are mistaken. You need 3 dimensions to represent a 3D rotation (2 for picking an axis, plus one for picking an angle). To represent translations and rotations together, you need 6 dimensions. This also shows that the talk of needing to visualize 4d to understand quaternions is disingenuous. The formula for using a quaternion to rotate a vector is qvq^-1, from which it is immediate that changing the length of a quaternion does not change the rotation it represents. So you can just deal with unit-length quaternions, which form a 3D space.
- diegoperini 7y agoPutting content aside (it's great actually), I love the format used for the article. Each header is also a link to a time point in the accompanying video. There are interactive canvases that are also used in the video. The only missing part is a teacher AI which I can ask questions to (just kidding).
- cambalache 7y agoThis article suffers from the syndrome -I learned what a hammer is, everything now looks like a nail- .
- friendlybus 7y agoIn what way? The blanket application?
- DonHopkins 7y agoI learned what math is, everything now looks like a number.
- rytill 7y agoI learned what a relation is, everything looks like it can be compared to other things. I learned what a function is, everything looks like a mapping between two sets. Wait...
- DonHopkins 7y agoIt all boils down the fight between King Azaz -vs- The Mathemagician. https://thephantomtollbooth.fandom.com/wiki/King_Azaz https://thephantomtollbooth.fandom.com/wiki/King_Azaz >King Azaz, ruler of Dictionopolis: King Azaz the Unabridged is the ruler of words. His law is that words are much more important than numbers. He is the brother of the Mathemagician who is the ruler of mathematics. They came in agreement that numbers and words are equally important in the end. King Azaz is a lot like his brother, only the ruler of words. However, unlike his brother, Azaz is more like a stereotypical ruler. He takes the title of king, he lives in a palace, and he encourages his subjects to attend banquets. https://thephantomtollbooth.fandom.com/wiki/The_Mathemagician https://thephantomtollbooth.fandom.com/wiki/The_Mathemagicia... >The Mathemagician, ruler of Digitopolis: The Mathemagician is the brother of King Azaz and ruler of Digitopolis. His law in Digitopolis is that numbers are far more important than words, while King Azaz's law is that words are more important than numbers. The Mathemagician is pretty much polite but gets really mad whenever somebody mentions that numbers aren't that important or valuable, since numbers mean so much to him.
- deleted 7y ago[deleted]
- alpineidyll3 7y agoThe author is missing a huge very real advantage of quaternions, that they are smooth functions of thier parameters and don't suffer from gymbal lock singularities. All 3d representions do, as can be shown with the math this guy is too lazybrained to do. That really matters for defining smooth paths, quaternions simply have the right topology and rotations don't.
- nmca 7y agoDid you read the article? Irrc you can lerp rotors and the results are smooth and interpretable...
- moultano 7y agoYou should read the article before commenting.
- eigenspace 7y agoThe author is using geometric algebra to create mathematical objects with all the same properties as quaternions, but to explain and understand them in a more comprehensive, sensible way. These things have all the same rotational properties as quaternions. In particular, he’s explaining that quaternions are not vectors, they’re actually oriented planes and showing how their multiplication rules arise in a way that’s not ‘out of thin air’.
- ArtWomb 7y agoWhen I was learning graphics, the reasoning around quaternions was to avoid "gimbal lock". It was just taken as orthodoxy without question. I think going forward next gen 3D engines will have to account for the improvements in GPU hardware realized by advances in machine learning. Mixed precision matrix multiply at massively parallel scale. As well as the demands of next-gen games. Things like real time ray tracing of deformable meshes ;)
- phlakaton 7y agoSame critique as I have for the article, though: just because the subject is poorly taught doesn't necessarily mean that the subject needs to be replaced. The key here is that gimbal lock isn't a feature of quaternions, it's a feature of Euler angles: https://math.stackexchange.com/questions/8980/euler-angles-and-gimbal-lock https://math.stackexchange.com/questions/8980/euler-angles-a...
- alejohausner 7y agoQuaternions can be normalized, thus eliminating numerical errors than can accumulate if you multiply a rotation matrix many times. These numerical errors make the matrix non-unitary, and introduce weird stretches and skews into the transformation.
- iorrus 7y agoThe reason many people have trouble understanding quaternions is that they reason about them incorrectly. Quaternions are actually a separate 'thing' when compared to vectors (which is why their multiplication seems off and the square is a negative number). Quaternions should be considered a versor (a rotation around great circles), that is a change in direction which is different from a vector. See this work: https://archive.org/details/cu31924001506769/ https://archive.org/details/cu31924001506769/
- DonHopkins 7y agoFrom the title, I was expecting to read an article by a crazy old retro mathematician shaking his fist and yelling at clouds that we should all go back to using Euler angles. But this was a much better article than the title suggested!
- dahart 7y ago> As a side note, Geometric Algebra contains more than just Rotors, and is a very useful tool to have in one's toolbox. I worked in a game engine where a pair of mathy programmers fell in love with Geometric Algebra, and use this same argument that quarternions ought to be replaced to overhaul all of the math code in the engine using Geometric Algebra. The character rigging system removed matrices and used GA instead. This caused several large problems in the code base: For one, it slowed the code down a little because the GPU interface is all matrices, so there were conversions to matrices all over the place, rigging in particular. And only two guys in the studio knew Geometric Algebra, and they didn’t invest time in teaching it or helping people understand it, they just hoisted it on everyone. All the rest of the programmers knew matrix math but not Geometric Algebra, so they would end up avoiding touching any of the GA code, i.e., any code that dealt in transformations. The two guys ended up with a lot of support of their own creation, but they were short with their answers, in part because they got so many questions, so the problem never went away. The third problem is this whole rewrite was unnecessary. Fixing gimbal lock with quaternions is a tiny corner of the game engine, whereas using GA throughout is a massive rewrite. Matrices work really well for 98% of the code, and it’s not really a huge problem to have one or two routines that convert to quaternions and back while they do a rotation. It is a problem when any transform at all involves bivectors and rotors and you have no idea what the hell those are nor do you have time in your schedule to take a math class at work. Personally, I’m intrigued by GA and have wanted to learn it for a while, but having used it in production, I’m mildly against replacing quaternions with GA, and very wildly against replacing matrices with GA.
- jessermeyer 7y agoThese problems are not inherent of GA, but of (flawed) implementation details and deeper social problems. GA code boils down to essentially the same computations as 'raw' Linear Algebra, and should be implemented as such. Your math centered programmers fell in love with the idea without ever figuring out how to really use it.
- dahart 7y agoI completely agree it wasn’t inherent to GA, but I wouldn’t summarize it as they didn’t figure out how to use it. They were fluent, the problem is the rest of us weren’t. The problem with what they did, and what this article is doing, is suggesting we “fix” something that takes 2 or 3 math classes to understand by replacing it with something that takes an entire semester to understand. I honestly believe that GA has insights to offer, but I don’t believe it will save any time to upgrade the use of quaternions in any 3d engine.
- nbulka 7y ago"We just accept their odd multiplication tables." What is odd about the quaternions' multiplication tables? Is it the fact that the commutative property of multiplication is violated? For the sake of argument, let me assert that it is. What if at the highest level of abstraction x * y had no obligation to equal y * x?
- rytill 7y agoSo what else does this operator do? It’s not commutative. Does (x * y) * z still equal x * (y * z)?
- yiyus 7y agoThe geometric and exterior products used in GA are non-commutative too.
- timerol 7y agoIt is definitely not that, since the article shows that a^b = -b^a. I suppose that it's the choice that ij = k as opposed to -k? I'm not sure, but the article's implication that nobody else cares why things work to be distracting and insulting. > Personally, I have always found it important to actually understand the things I am using.
- danmg 7y agoThose who don't understand quaternions are condemned to reinvent it, poorly. I work in a research field that uses rotations heavily, and trying to use things like Euler angles (with 4 or 5 competing representations) and axis angles has created nothing but confusion among people. If people used quaternions from day one, it probably would have saved, cumulatively, the time of several dozen phds.
- jessaustin 7y agoWhat research field is this? Why hasn't one of the researchers made the conceptual leap you propose?
- danmg 7y agoIt has to do with metallurgy. Some people do use them, but most work is done with euler angles.
- 6gvONxR4sf7o 7y agoI think you misunderstand the article. It's not saying to replace them with euler angles or axis angles or anything analogous. GA is among other things a more intuitive mental model of quaternions.
- OliverJones 7y agoAs we kiss these quaternions goodbye, let's remember how they came to be, and their role in building the discipline: Ivan Sutherland's early hardware graphics pipelines.
- wbl 7y agoYes, the even Clifford algebra is the quaternions. So what?
- Koshkin 7y agoThey say Geometric Algebra is "the new language of physics" and whatever else; my problem with this is that, unlike, say the calculus of differential forms (or tensors), it does not make sense in more general manifolds which are at the heart of the modern theoretical physics. Geometric Algebra, therefore, is more like something that, sure, could be taught in high school in an attempt, for example, to streamline elementary vector algebra and thus eliminate some nasty questions (should they arise); yet, there is some mental load to it that may make it not worth the effort...
- moultano 7y agoCan you elaborate on that or provide a link? The OP made it seem like it was strictly more general, and I was getting excited to dive in through that route.
- Koshkin 7y agoWell, nothing wrong with getting excited about and learning this stuff. Point was, in more complicated cases like (non-flat) [co]tangent bundles GA, as an intuitive framework, loses any advantage, perceived or real, over differential forms.
- 6gvONxR4sf7o 7y agoI found that learning geometric algebra in a nice flat space made differential forms much more intuitive for me. I don't think they're so at odds, and teaching one then the other may benefit both.
- BlueTemplar 7y agoUh, getting rid of pseudo-vectors ? Maxwell's Equations? http://www.av8n.com/physics/maxwell-ga.htm http://www.av8n.com/physics/maxwell-ga.htm
- zrkrlc 7y agoHuh, it absolutely does. Alan Macdonald wrote a book about geometric calculus and made a companion video series for it. Here’s the section defining manifolds: https://www.youtube.com/watch?v=jfwdlW7Yr_I https://www.youtube.com/watch?v=jfwdlW7Yr_I That said, tensors are in fact more general than geometric algebra’s multivectors (in that the latter form a quotient algebra of the former). But not all tensors correspond to manifolds as we know them in physics and I argue that GA keeps track of the geometric properties we want better.
- thrower123 7y agoNice thought, perhaps, but I doubt anything would come of it. Quaternions came into vogue because the problems of Euler angles were very apparent in practice, but we still think, at best, in yaw/pitch/roll, and for a lot of people, roll is a little on the sketchy side. Now we have twenty, twenty-five years of code and resources that make use of quaternions. In some ways, game development is incredibly hide-bound and conservative, and for the most part eschews rigid correctness for performance, convenience, and a loosey-goosey good 'nuff feel.
- edflsafoiewq 7y agoHe's not actually proposing any change. He just gives a different construction of the usual quaternions.
- VikingCoder 7y agoWhile we're at it, can we please move the homogeneous coordinate to be the first value in memory? That way, a vector or a point, if they're represented sparsely in the data structure, just work. [1], a point at the origin, is the same as [1 0] - a point at the origin in 1 dimension, or as [1 0 0], a point at the origin in 2 dimensions, or [1 0 0 0], a point at the origin in 3 dimensions. Similarly, [0] is a zero vector. [0 0 0 0] is a zero vector in 3 dimensions. Having to know [0 0 1] is a point at the origin in 2 dimensions (with a homogeneous coordinate), while [0 0 1] is a z vector in 3 dimensions (without the homogeneous coordinate), is just silly. Why did we do this to ourselves?
- joppy 7y agoIt’s puzzling - even in most of the mathematical literature, x_0 is used for the homogeneous coordinate.
- orbots 7y agoMemory layout. You can do a hacky "cast" from a homegeneous 4-vector to a ideal 3-vector for free. Same pointer.
- joppy 7y agoThis would mean that you have to make sure elsewhere in your code that the last coordinate is always normalised to 1, so do you win overall using this strategy? Plus, the same cast in the other method is ptr+1, which is assumedly just as fast.
- spacedome 7y agoAmusingly the discovery of Quaternions by Hamilton was also followed by arguments within the mathematical community as to whether mathematics should be rewritten in the language of quaternions, as Hamilton proposed to do and subsequently spent the rest of his life pursuing. Initially many mathematicians found them confusing, Hamilton's book is unusually difficult to read and there were no others. The work of Grassmann was somewhat neglected at the time, and eventually the Gibbs/Heaviside notion of vectors (essentially what we use today) emerged as a competitor to the quaternions. It seems it was a particularly bitter mathematical divide, up there with Newton vs Leibniz. Here is a quote by Tait, one of the "quaternionists": "Even Prof. Willard Gibbs must be ranked as one of the retarders of quaternion progress, in virtue of his pamphlet on Vector Analysis, a sort of hermaphrodite monster, compounded of the notations of Hamilton and of Grassman" See "History of Vector Analysis" by Crowe or "Hamilton, Rodrigues, and the Quaternion Scandal" by Altmann. Nice to see the author cites these! The Geometric Algebra comes from Clifford Algebras, which where an attempt to combine Hamilton's Quaternions and Grassmann's forms, and in fact contains both as sub-algebras. In the case of 3D rotations calling them Rotors or Quaternions seems mostly like a different way of thinking about the same thing. I think this would be more kindly put as "reimagining" quaternions and not "removing" them. The additional geometric intuition from GA does seem useful, and even as someone who has used quaternions extensively (though in a very different context), I would also choose to work with Geometric Algebra as a framework for geometry over Quaternions. The visualizations are quite good here, it is a good way to understand bi-vectors, you can wiggle them about a bit in 3D instead of just staring at parallelograms on a page. The only criticism I have is that they say quaternions and the cross product come "out of nowhere", but then the way they present the geometric product is equally "out of nowhere".
- randName 7y agoI wonder if this has anything to do with the 4D game that he is working on. Do quaternions work in 4D space?
- gliese1337 7y agoYes, it does; and no, they don't.
- cygx 7y agoBut they do? A 4d rotation can be decomposed into a left-isoclinic and right-isoclinic rotation, which in turn can be represented by left- and right-multiplication with unit quaternions.
- gliese1337 7y agoThat's hardly the most straightforward or intuitive decomposition. In particular, it makes simple monoplanar rotations overly complicated, in exchange for making isoclinic rotations super simple--while rotors handle monoplanar rotations entirely naturally, with an obvious extension to isoclinic rotations. And monoplanar rotations are a much nicer primitive to work with.
- adam-a 7y agoThis is a very cool article which has left me wanting more. It seems to stop just short of the end though, there is no section to actually explain the component values in a rotor, or an interactive diagram deconstructing the component parts of a rotor. Or did I miss it? I'd also be really interested to see some more applications. I wonder what rotor interpolation looks like for example? I know I've had problems with quaternion interpolation in the past.
- o_p 7y agoMaybe the blog poster should try to learn how imaginary numbers work instead of trying to stick with reals, as an EE im probably biased but rotations -> complex numbers, as they make it much easier to work with it
- BlueTemplar 7y agoRotations in 2D - absolutely ! Rotations in 3D are a whole different beast...
- epicgiga 7y agoLet's remove them from one 3d engine first, and see how it goes.
- DreamScatter 7y agoCheck out my geometric algebra software https://grassmann.crucialflow.com https://grassmann.crucialflow.com The Grassmann.jl package provides tools for doing computations based on multi-linear algebra, differential geometry, and spin groups using the extended tensor algebra known as Leibniz-Grassmann-Clifford-Hestenes geometric algebra. Combinatorial products included are ∧, ∨, ⋅, *, ⋆, ', ~, d, ∂ (which are the exterior, regressive, inner, and geometric products; along with the Hodge star, adjoint, reversal, differential and boundary operators). The kernelized operations are built up from composite sparse tensor products and Hodge duality, with high dimensional support for up to 62 indices using staged caching and precompilation. Code generation enables concise yet highly extensible definitions. The DirectSum.jl multivector parametric type polymorphism is based on tangent bundle vector spaces and conformal projective geometry to make the dispatch highly extensible for many applications. Additionally, the universal interoperability between different sub-algebras is enabled by AbstractTensors.jl, on which the type system is built.
- skratlo 7y agoHoly cow, dude, I'm going to use this one to make people feel dumb. Craziest cryptononsense I've ever read!
- dang 7y agoPlease don't be a jerk in comments here. It's against the spirit of the site (and also its rules). https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- ComplexSystems 7y agoWhat does the differential operator do and how does it relate to geometric algebra?
- ajkjk 7y agoThere's a lot of connections between projective geometry and geometric algebra (well-- at least exterior algebra. Not sure about 'geometric', because I don't know what the geometric product means). If you implement _oriented_ projective geometry in homogenous coordinates (so a point (x,y) is a vector (x,y,1)), then the meet and join operators are implemented as ∧ and ∨. You can make a little dictionary: Join = ∧, Meet = ∨. Vector = point, Bivector = line, Trivector = area, etc. The figure spanned by points (a,b,c) = a ∧ b ∧ c. The boundary of the figure = ∧^(k-1) of the metric (a,b,c), equal to ∂(a,b,c) = a ∧ b + b ∧ c + c ∧ a. I have a very amateur blog that I never publicize about this stuff and I had a long post about this, but I've taken it down for now to rework it, or I'd link it here. Suffice to say there's a lot of connections and I feel like there are even more here that haven't been discovered yet. The book "Oriented Projective Geometry" by Stolfi has a lot of this, although it doesn't explicitly talk about geometric algebra or the wedge product -- but it uses all the same symbols. I'm on the lookout for a better reference that bridges the gap. [I have so far not figured out what the exterior derivative means in projective geometry, besides being dual to ∂; I believe that if derivative operators are just dual to basis vectors, then d is literally just dual to ∂. Not sure. I also have no idea what the geometric product means, and tend to be skeptical of it for that meaning.]
- Zenst 7y agoBit like arguing that another keyboard layout would be better and it would if your starting from scratch, but people tend to go with what they know and that propergates as accepted and good enough, a standard. Hence, whilst there are better layouts for keyboard, we still have QWERTY. Much the same with argument here, sure GA would be better, and maybe that may well come about, but alas quaternions are somewhat known by the many over the few and a bit of a QWERTY situation plays out.
- playing_colours 7y agoWhat is a good book you can advise for someone with maths background to dig into GA?
- bwidlar 7y agoGeometric Algebra in 2D - Fundamentals and Another Look at Complex Numbers: https://www.youtube.com/watch?v=PNlgMPzj-7Q&list=PLpzmRsG7u_gqaTo_vEseQ7U8KFvtiJY4K https://www.youtube.com/watch?v=PNlgMPzj-7Q&list=PLpzmRsG7u_...
- radarsat1 7y agoHm. I don't claim to fully understand quaternions, but I simply think of them as an obfuscated version of axis-angle representation, which seems to serve me well in reasoning about operations on them.
- pjbk 7y agoReading some comments here... * GA provides some nice savings when it comes to rotor/3D calculations, provided that the underlying data structures and architecture supports them. Check out the publications by Dietmar Hildenbrand and his team for several examples: - https://www.researchgate.net/profile/Dietmar_Hildenbrand https://www.researchgate.net/profile/Dietmar_Hildenbrand * Quaternions start to exhibit several limitations when dealing with complex objects, even in 3D. It provides just the necessary structure to store quadrature information to avoid the "gimball lock" issue, for example. However the fact that it collapses the scalar with the pseudoscalar presents several problems again in calculations with dual quaternions and higher dimensions (projections, for once), and it's not much different from the hurdle of having to discriminate axial and polar vectors in Vector Calculus. The main issue is that its handedness doesn't scale well and has problems capturing the geometric nature and physics of the world in several dimensions (ie symplectic geometry). * IMHO the real usefulness of GA is that, as it name implies, it's an algebra. That is what Clifford, Ball, Lie and Klein realized while extending the work of Grassmann on exterior algebras, screw theory, vector spaces and differential forms. Matrices, quaternions and some forms have awkward behaviors when they are treated symbolically as algebraic objects, being "leaky" on information or having singularities just because they are not the best representation. GA fixes that allowing you to formulate problems symbolically, and then you can almost blindly solve the equations with high confidence that the result will be sound. You can then convert the objects back to your favorite representation. For good examples, check out Terje Vold papers on: - Rigid body dynamics: https://www.researchgate.net/publication/241273951_An_Introduction_to_Geometric_Algebra_with_an_Application_in_Rigid_Body_Mechanics https://www.researchgate.net/publication/241273951_An_Introd..., and - Electrodynamics: https://www.researchgate.net/publication/245345681_An_introduction_to_geometric_calculus_and_its_application_to_electrodynamics https://www.researchgate.net/publication/245345681_An_introd...) [Note: Watch out for some typos]. For comparison, take a look at Featherstone's 6D Spatial Vector representation, which is similar to screws and I think shows the best you could do with Vector Calculus objects: - http://bleyer.org/files/A%20Beginner's%20Guide%20to%206-D%20Vectors%20-%20Feathersone%20(IEEE,%202010).pdf http://bleyer.org/files/A%20Beginner's%20Guide%20to%206-D%20....
- scythe 7y agoHis criticism of the cross product seems more poignant than his criticism of quaternions in computer programming. One might ask -- why not teach bivectors in introductory math instead of cross products? Historically it seems like 3D geometry and particularly cross products in the context of electromagnetism fomented the primary demand in mathematics education for students to be taught vectors. Unfortunately the mathematics curriculum (in Western countries) has not really been updated in decades to better prepare students for the jobs of today; we still enroll all students in a sequence that culminates in differential equations and particularly in second-order linear differential equations, which just so happen to be crucial to control problems in electrical and mechanical engineering. While many people's jobs involve some kind of mathematics somehow, only a few jobs involve the mathematics of electrical engineering, and I suspect that is part of the reason why so many students are bored in math class.
- BlueTemplar 7y agoPuzzles me too. And even further : IIRC, you don't need cross-product for electrical engineering, and IIRC it (thankfully) isn't (generally?) taught in high school. Furthermore, later, in college, it would seem that electromagnetics get easier when taught through bivectors rather than cross products (and you avoid the traps with pseudo-vectors and, later, gimbal lock with Euler angles ?). Maxwell's multiple equations seem to condensate to a single one under GA ! (What if we teach GA it will open the possibility of teaching EM in high school ?)
- GlenTheMachine 7y agoA point that I don't think has been mentioned here: quaternions as a representation of attitude are really just a funky parameterization of an Euler axis/angle representation. Quaternions happen to be parameterized in a way that lets you avoid the evaluation of trigonometric functions when expressing their dynamics. This used to be important, e.g. in aircraft control systems, because computing power was extremely limited and you didn't want to have to evaluate sines and cosines in real time. The biggest disadvantage of using quaternions over Euler axis/angle representations is that quaternions are basically impossible for humans to visualize, whereas Euler axis/angle representations are easier than transformation matrices, Euler angles, or any other representation. So why not just use Euler axis/angle representations instead? Nobody cares any more about evaluating cosines at 1 kilohertz, and there would be none of this complicated geometric algebra stuff that nobody understands.
- rationalfaith 7y agoDude Le-performance is always important. Helper functions can be added for readability but perf perf perf perf.
- cygx 7y agoSo why not just use Euler axis/angle representations instead? Composition of two rotations in axis/angle representation basically proceeds via the quaternionic formula, ie in terms of half-angles. So if you need to do that a lot, it makes sense to go fully quaternionic to avoid having to work with both full and half angles.
- crubier 7y agoI am impressed at the number of people reacting with « Euler angles are fine » or « quaternions are fine, we always did this way ». Having worked extensively with them it is obvious that Euler angles are broken beyound repair (singularities, 12 competing variations...) and quaternion are too (they only work in 3D). This article is extremely interesting and absolutely true. If geometric algebra had been discovered earlier we would never have needed a lot of these unnatural constructs.
- QuesnayJr 7y agoBecause we're going to start doing computer graphics in 4D?
- crubier 7y agoWe already do! You seem to ignore the widespread use of projective geometry in all 3D engines. For me it shows that you don’t know enough about the topic to have a useful opinion on this. We do 4D stuff in 3D engines because it leads to massively nicer and simpler math, like replacing extremely large trigonometric calculations with a few additions and multiplications. It is actually the right way to do things. And bonus fact: it actually makes logical/intuitive sense when you actually try to understand the math.
- QuesnayJr 7y agoThat's hilarious, because I've studied projective geometry for years. I am literally writing a paper based on projective geometry right now (applied to abstract algebra). Projective coordinates still gives you a three-dimensional object, because you identify vectors that are scalar multiples of each other.
- crubier 7y agoOk look just watch this mind blowing video: https://youtu.be/tX4H_ctggYo https://youtu.be/tX4H_ctggYo After that, you can’t argue that geometric algebra is not THE right way to do geometry. Projective geometry (in any dimension) is a subset of geometric algebra. Please watch it.
- ChrisLomont 7y agoHaving written engines using both GA and matrices+quats, as well as writing articles on GA (one intro one in an old Games Gems book), I'd say GA is a terrible idea for 3D engines. GA is inherently slower to manipulate, as items require more storage and more memory touches. They add almost zero benefit. If the idea is use a higher, more pure math structure, then one can go to even more abstract math formalisms, such as coord-free calculus and bigger algebras, but these, like GA, add more computational overhead to solve problems that don't exist. Hestenes et. al., the main popularizes of GA in the math/programming intersection, have papers on writing raytracers in both, and they too clearly demonstrate loss of performance using GA.
- overgard 7y agoWorth noting that the author is the guy behind this extremely interesting project to create a 4D puzzle game: https://miegakure.com/ https://miegakure.com/ He's given a lot of talks on subjects like this. I imagine that what he's doing mathematically is a lot more intricate than most games need though.
- ahaferburg 7y agoOh, thanks for pointing that out! He posted an update on the game recently: https://marctenbosch.com/news/2020/01/miegakure-update-end-of-2019/ https://marctenbosch.com/news/2020/01/miegakure-update-end-o...
- thisrod 7y agoI like this as an introduction to exterior algebra. It would be nice if the article mentioned the Hodge star, and explained why you can identify any form with a vector in 3D, even when it might be clearer not to.
- QuesnayJr 7y agoThis is the exact kind of clickbait title that HN normally changes to something less inflammatory. Every time I see the title I feel my blood pressure going up.
- WAHa_06x36 7y agoIsn't the only difference between rotors, as defined in this article, and quaternions the sign of the second 3d component? And this only happens because the planes are defined as "xy", "xz" and "yz", rather than the more consistent "xy", "yz" and "zx"? If you just changed the definition of the planes at the start of the derivation, it seems you would end up deriving the exact same operations as you would use with quaternions? I'm not sure if there is a good argument for not doing that.
- skywal_l 7y agoIs the outer product the same thing as the exterior product? Wikipedia gives different definitions. That's why I was a little confused by the article initially. Something to keep in mind.
- chombier 7y agoIt is somewhat strange that all these articles/blogs claiming that Geometric Algebra is inherently superior to Quaternions spend so much time on how Quaternions are isomorphic to the even-subalgebra of GA3 (hence for all intents and purposes they're the same) and so little time on the odd-subalgebra (exterior algebra IIRC), which as far as I can tell is the main (only?) advantage of GA over Quaternions. On the other hand, almost nobody mentions the nice geometric perspective that unit quaternions offer that are somehow "lost in translation" in GA: as a compact Lie group, unit quaternions come endowed with a bi-invariant Riemannian metric which means you can do interpolation, clustering, blending, statistics with them in a metric-consistent manner. And since the metric is compatible with the group structure, the geodesics are cheap to compute.
- amai 7y agoLet's also remove bivectors and instead use skew-symmetric matrices ( https://en.wikipedia.org/wiki/Skew-symmetric_matrix https://en.wikipedia.org/wiki/Skew-symmetric_matrix ) . The modern matrix notation is so much more powerful and flexible than all those 19th century inventions like complex numbers, quaternions, bivectors, dual numbers, ... that we should really stop teaching all those old confusing stuff.