Live data from Hacker News

Let's remove Quaternions from every 3D Engine

marctenbosch.com

91–100 of 184 posts

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

#91
post #39

Texts on GA seem to start out saying "we're going to replace vector analysis with something intuitive and natural and eloquent and..." and then immediately introduce the "geometric product", which is neither intuitive, eloquent, or, as far as I can tell, natural. Its properties are found via formula-wrangling, and the results you get from it seem to just magically work, rather than being intuitive. Bivectors in gener…

The geometric product is super useful and important! (As well as much nicer to work with when doing algebraic manipulation.) In particular, it is what lets you take products, inverses and quotients (assuming the denominator is non-null) of arbitrary vectors. > surprisingly hard to compute Hm? No it isn’t.... Several times in the last few years I have done several pages of complicated calculations in terms of coordina…

It is easy to compute on vectors. It is possible, but complicated and unintuitive (I have written code to do it in the past), to compute it on multivectors.

I'm arguing in favor of most of GA's language. I just keep finding that the wedge and inner product parts are fantastic, and the geometric product part isn't. And I think the reason people keep finding GA appealing is because they didn't have the wedge product before, so having that in their conceptual toolkit fixes a lot, while having the geometric product doesn't fix much on top of it. Anyway I've studied GA a lot and I still have basically no idea what 'AB' means when both are arbitrary-grade multivectors, and as far as I can tell most sources don't even try to explain it.

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

#92

This article reads like 'I don't understand quaternions therefore they're bad.' Like what - they are the objectively best representation of rotations...

That's not at all what the author is saying. The author actually has a much deeper understanding of quaternions than most of their users and realizes that they are part of a much more general and useful structure known as the 3D geometric algebra and he advocates using that instead of quaternions. GA(3) use objects that are isomorphic to quaternions to represent rotations but is much more comprehensible and generaliz…

OK sorry, that was rash of me to say.

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

#93

Earlier quoted context omitted.

And if you don’t want to take the logarithm per se, you can bisect the rotation A by taking the sum of your rotor + 1, and then normalizing the result by dividing by the magnitude, (A + 1) / |A + 1|. Or if you have two rotors A and B, you can interpolate halfway between by taking (A + B) / |A + B|. This requires seven additions, four multiplications, one division, and one square root.

I would replace the last two operations by another multiplication and one reciprocal square root. There is extensive SIMD support for very fast approximations, and getting better in newer chips.

Yes of course. I just mean, conceptually that is what is required. You can replace a bunch of the multiplications and additions by FMA instructions as well.

By the way Raph, I think you might be interested in this draft paper I have been working on (well, not working on for the past two months, but anyway...)

https://beta.observablehq.com/d/e639659056145e88

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

#94
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 to derive it.

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

#95
post #31

Earlier quoted context omitted.

You can take the logarithm of a rotor in order to do interpolation. If you want a transformation represented by a rotor R to happen in N steps, you can apply R ^ (1/N) N times. The Nth root of R is exp(log(R)/N)

The same is true (with lower performance, I suspect) with the 3x3 matrix representation.

It's beautiful to see that the logarithm of a rotation matrix is a skew-symmetric matrix. The skew-symmetric matrices correspond to angular velocity, which behave like vectors. You can add and interpolate as you expect. Rotation matrices multiply. Skew-symmetric matrices add. The logarithmic and exponential map moves between the two spaces.

Just letting you know that I think it's valuable to bring up matrices into this discussion, even if they do have problems in practice with rounding errors and efficiency.

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

#96

It's completely unnecessary to understand what the individual components of quaternions represent. All that is necessary is to build an understanding of what the operations do for you. Do you need to understand Russell's proof that 1+1=2 to compute the tip on your bar bill, or do you just need to know what to expect when you apply the addition operation to two numbers? Treat quaternions as indivisible whole values as…

I will give you an example (from my recent work) where actually knowing what the components mean was useful.

I had to calculate misorientations between many pairs of orientations. If I treated quaternions as a whole, I would find their quotient and then get the angle. But since I know what the components mean, and I know I can get the misorientation angle from just the cosine (the scalar component), and I know that I can get this value from a simple dot product, I can easily save a few operations to calculate every misorientation. And since I have to calculate many of them, this change supposed a big speedup.

Black boxes are nice when learning or thinking at a high level, but if you frequently use a black box, knowing what is inside will probably become useful at some point.

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

#97

Earlier quoted context omitted.

The same is true (with lower performance, I suspect) with the 3x3 matrix representation.

It's beautiful to see that the logarithm of a rotation matrix is a skew-symmetric matrix. The skew-symmetric matrices correspond to angular velocity, which behave like vectors. You can add and interpolate as you expect. Rotation matrices multiply. Skew-symmetric matrices add. The logarithmic and exponential map moves between the two spaces. Just letting you know that I think it's valuable to bring up matrices into th…

Skew symmetric matrices are isomorphic to bivectors :)

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

#98

This article will take more than than I have to digest right now, but it's definitely saved. I have never really understood quaternions. All I knew is that I could use that instead of euler angles, avoid gimbal lock, and would blindly use them.

I'd argue that this geoemtric algebra presented in the article is much more comprehensible than quaternions and also more useful!

But if the argument is "let's replace quaternions in 3D engines!" then the question is really more "Okay, so do they outperform quaternions, then??" because if you're writing the 3D engine, the underlying code only matters insofar as that it has to do what it's supposed to do. You don't need to understand why it works, just that known operations will lead to known intended results. And if you're _using_ a 3D engine, you shouldn't even care. You just want rotation to work in the least amount of time, with the fewest function calls. What happens at the engine level, hidden by those functions, is entirely irrelevant.

And I don't see a case being made that demonstrates that for the purpose of a 3D engine, this actually "makes more sense". It's just a different way to compute the exact same results. If I'm writing a game, or simulation, or 3D visualisation, I literally don't are how the engine does what I tell it to do, as long as it does it.

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

#99
post #91

Earlier quoted context omitted.

The geometric product is super useful and important! (As well as much nicer to work with when doing algebraic manipulation.) In particular, it is what lets you take products, inverses and quotients (assuming the denominator is non-null) of arbitrary vectors. > surprisingly hard to compute Hm? No it isn’t.... Several times in the last few years I have done several pages of complicated calculations in terms of coordina…

It is easy to compute on vectors. It is possible, but complicated and unintuitive (I have written code to do it in the past), to compute it on multivectors. I'm arguing in favor of most of GA's language. I just keep finding that the wedge and inner product parts are fantastic, and the geometric product part isn't. And I think the reason people keep finding GA appealing is because they didn't have the wedge product be…

I’m telling you that after a few years working with the geometric product a whole bunch, the wedge product really doesn’t cut it.

> I still have basically no idea what 'AB' means when both are arbitrary-grade multivectors

Any mathematical language (or any natural language) can express a bunch of nonsensical and useless things. What is the sine of the square root of the logarithm of the tangent of some polynomial applied to a scalar? Who knows?!

You can certainly make up nonsensical expressions using matrices, differential forms, etc.

In a concrete problem, sometimes you have to think a bit to figure out what the geometrical meaning is of a particular multivector, but if the problem came out of a physical situation, I haven’t yet found a case where I couldn’t explain it.

Your multivector might be an electromagnetic field. It might be a rotor. It might be a representation of a sphere in the conformal model, ...

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

#100
post #91

Earlier quoted context omitted.

It is easy to compute on vectors. It is possible, but complicated and unintuitive (I have written code to do it in the past), to compute it on multivectors. I'm arguing in favor of most of GA's language. I just keep finding that the wedge and inner product parts are fantastic, and the geometric product part isn't. And I think the reason people keep finding GA appealing is because they didn't have the wedge product be…

I’m telling you that after a few years working with the geometric product a whole bunch, the wedge product really doesn’t cut it. > I still have basically no idea what 'AB' means when both are arbitrary-grade multivectors Any mathematical language (or any natural language) can express a bunch of nonsensical and useless things. What is the sine of the square root of the logarithm of the tangent of some polynomial appl…

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 where the other holes are yet.

Post reply on HN