Live data from Hacker News

Let's remove Quaternions from every 3D Engine

marctenbosch.com

141–150 of 184 posts

Re: Let's remove Quaternions from every 3D Engine

#141

Tangential: Back in 2000 there was some debate about dropping quaternions in favor of a set of equivalent operations on plain matrices. https://www.gamedev.net/articles/programming/math-and-physic... The debate petered out when the proponents finished optimizing their implementation and found they had produced exactly the same code as the existing quaternion implementations. The only difference was the approach used…

In high level programming, the code is for humans, the optimized compiler output is for the computer.

Re: Let's remove Quaternions from every 3D Engine

#142

Tangential: Back in 2000 there was some debate about dropping quaternions in favor of a set of equivalent operations on plain matrices. https://www.gamedev.net/articles/programming/math-and-physic... The debate petered out when the proponents finished optimizing their implementation and found they had produced exactly the same code as the existing quaternion implementations. The only difference was the approach used…

Thank you for posting this, I found it both very enlightening and a pretty fun internet-drama read :D Interesting that the original complaint of that article/thread and this one are both the same - ie. quaternions are 'too hard to understand', and people 'use them without knowing how they work'. With this being posted so soon after https://news.ycombinator.com/item?id=18310788 , I feel like that complaint is less val…

Matrices are linear transformations. Take a bunch of vectors, map them to another bunch of vectors. It's all inherently geometric.

The matrix:

  adg
  beh
  cfj
maps the vector (1,0,0) to the vector (a,b,c), (0,1,0) to (d,e,f), etc... so if you write any other vector as a weighted sum of (1,0,0), (0,1,0), etc... the weights get mapped to the new vectors.

As someone with a background in physics and geometry, it seems bizarre to me to use quaternions to reason about geometry. It's really unnatural. It's basically just a coincidence that the algebraic structure of rotations in 3d happens to look like this. It doesn't generalize to higher dimensions. There is no equivalent to quaternions for 4, 5, 6d [1].

Bivectors discussed in the article, on the other hand, easily generalize to higher dimensions, and are a completely natural geometric concept. (Of course if your thesis is about constructing 4d objects you care about that a whole lot more than if you build a 3d engine...)

Now that doesn't mean it's easier or harder to manipulate one or the other. As they all reference the same mathematical structure it's also not surprising that the code ends up being the same. And given that algebra is more natural for computers, I can see why quaternions might be useful here. But geometric they are not.

[1] https://en.wikipedia.org/wiki/Composition_algebra

Re: Let's remove Quaternions from every 3D Engine

#143

Earlier quoted context omitted.

If the results are going to be the same, then what's the possible benefit for any user of a 3D engine? Things like the ability to "generalize everything to pseudo-Euclidean spaces or to lower or higher dimensions", algebraic tools and writing proofs are not relevant to the needs that a 3D engine serves - 3D engines are written to fulfil requirements of engine users (not even engine writers), who won't be doing such t…

> If the results are going to be the same, then what's the possible benefit for any user of a 3D engine? If it is going to be compiled down to the same binary code, what's the possible benefit of any higher level language?

From the possible options I listed above, (c), a substantially easier API.

On the other hand, if it's not exposed to the user, it doesn't particularly matter what structures and math that higher-level language uses behind the scenes to do what it does; most aspects of compiler theory are irrelevant for users of high-level languages.

Re: Let's remove Quaternions from every 3D Engine

#144
post #100

Earlier quoted context omitted.

To be clear, I don't think the wedge product is sufficient either; I just think it's the real reason most people end up finding GA to be appealing. I think there's work to do to clean the whole space up. Particularly, the wedge product is a 'join' or 'union' operator (amusingly, it has the wrong symbol). The 'meet' operator is not widely known but should probably be equally prominent. I haven't figured out for myself…

You might enjoy https://arxiv.org/abs/1205.5935

As someone unable to fathom the enthusiasm for geometric algebra... at least this defines this product: It's the sum of an inner product and a wedge product. Acting on two vectors these give a scalar and a 2-form. Why is adding these different objects a good idea? Don't they have different units (like, a pure number vs meters squared)?

Re: Let's remove Quaternions from every 3D Engine

#146
post #100

Earlier quoted context omitted.

To be clear, I don't think the wedge product is sufficient either; I just think it's the real reason most people end up finding GA to be appealing. I think there's work to do to clean the whole space up. Particularly, the wedge product is a 'join' or 'union' operator (amusingly, it has the wrong symbol). The 'meet' operator is not widely known but should probably be equally prominent. I haven't figured out for myself…

You might enjoy https://arxiv.org/abs/1205.5935

Thanks for that, it's a really good explanation!

Re: Let's remove Quaternions from every 3D Engine

#147

Earlier quoted context omitted.

Thank you for posting this, I found it both very enlightening and a pretty fun internet-drama read :D Interesting that the original complaint of that article/thread and this one are both the same - ie. quaternions are 'too hard to understand', and people 'use them without knowing how they work'. With this being posted so soon after https://news.ycombinator.com/item?id=18310788 , I feel like that complaint is less val…

Matrices are linear transformations. Take a bunch of vectors, map them to another bunch of vectors. It's all inherently geometric. The matrix: adg beh cfj maps the vector (1,0,0) to the vector (a,b,c), (0,1,0) to (d,e,f), etc... so if you write any other vector as a weighted sum of (1,0,0), (0,1,0), etc... the weights get mapped to the new vectors. As someone with a background in physics and geometry, it seems bizarr…

There is an N-dimensional generalisation for complex numbers, quaternions and hypercomplex numbers called Clifford algebra. I'm not an expert in that field (coming from physics and optics) but apparently it's not by chance that quaternions are connected with the rotation group SO(3) and complex numbers with SO(2). You can generalize to SO(n) with Clifford algebra.

Re: Let's remove Quaternions from every 3D Engine

#148

Earlier quoted context omitted.

I’d love to see a small GitHub repo that contains Rotators and Quaternions with compared results.

The results are going to be the same. The arithmetic involved is literally identical. The real power of the GA version is that you can more clearly geometrically explain what is going on, and you can generalize everything to pseudo-Euclidean spaces or to lower or higher dimensions. GA gives you some more algebraic tools to work with, so when you are trying to write your proofs they are clearer and more concise.

> The arithmetic involved is literally identical.

So to "remove Quaternions from every 3D Engine" all we need to do is rename the "Quaternion" datatypes to "Rotor" and we're done?

Re: Let's remove Quaternions from every 3D Engine

#149
post #112

Earlier quoted context omitted.

Rust seems to have better (free, at least) documentation, though.

It also offers more in the way of concrete benefits.

Not sure if you are ironic and what are you referring to by "it", but in any case I was mocking both rust and GA.

In all seriousness, both rust and geometric algebra are really very cool; but their proponents are so ridiculously over-enthusiastic that it is easy to get tired of them before taking them seriously.

Re: Let's remove Quaternions from every 3D Engine

#150

Earlier quoted context omitted.

Matrices are linear transformations. Take a bunch of vectors, map them to another bunch of vectors. It's all inherently geometric. The matrix: adg beh cfj maps the vector (1,0,0) to the vector (a,b,c), (0,1,0) to (d,e,f), etc... so if you write any other vector as a weighted sum of (1,0,0), (0,1,0), etc... the weights get mapped to the new vectors. As someone with a background in physics and geometry, it seems bizarr…

There is an N-dimensional generalisation for complex numbers, quaternions and hypercomplex numbers called Clifford algebra. I'm not an expert in that field (coming from physics and optics) but apparently it's not by chance that quaternions are connected with the rotation group SO(3) and complex numbers with SO(2). You can generalize to SO(n) with Clifford algebra.

This is closely related to the exterior algebra, which is where bivectors live. But I don't know much about Clifford algebras either. I didn't know that they are more directly connected to Quaternions. Thanks!
Post reply on HN