Live data from Hacker News

Let's remove Quaternions from every 3D Engine

marctenbosch.com

171–180 of 184 posts

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

#171

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.

There was an excellent article posted to HN a few years back about Clifford algebra you (and GP) might find interesting:

https://slehar.wordpress.com/2014/03/18/clifford-algebra-a-v...

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

#172
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 way this text does the geometric product is trying to be intuitive by immediately giving a "physical" interpretation as the sum of the inner and outer products. However the physical interpretations breaks down when trying to multiply three of these together.

I think Ben Lynn's approach is actually better: https://crypto.stanford.edu/~blynn/haskell/ga.html (Part 1)

It starts off more abstract, defining the geometric product simply as string concatenation (as in "free monoid" if you're familiar with that term, which you would if you have intermediate Haskell knowledge) plus a very natural constraint. From this natural constraint one can then deduce the sum-based interpretation that the OP gives.

The natural constraint is then further generalised and justified in more detail in Part 3: https://crypto.stanford.edu/~blynn/haskell/cga.html

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

#173
post #131
post #89

Earlier quoted context omitted.

I learned about differential forms in my physics degree, and then later discovered that the exterior algebra made a lot more sense if you introduced it separately. Basically it seems like the exterior algebra is useful in many settings, and differential-forms are just one rather confusing application of it. My current opinion is that exterior algebra should, someday, be taught first (around the time of linear algebra…

The Hodge star isn't so bad: It's just the generalization of the idea that you can describe a plane by its normal vector.

On it's own it's not bad, but it's troublesome because given a complicated expression with wedges and stars, it's not at all intuitive how you can simplify it without working in coordinates.

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

#174
post #173
post #131

Earlier quoted context omitted.

The Hodge star isn't so bad: It's just the generalization of the idea that you can describe a plane by its normal vector.

On it's own it's not bad, but it's troublesome because given a complicated expression with wedges and stars, it's not at all intuitive how you can simplify it without working in coordinates.

Is there a silver bullet, though? The complexity of having to mess around with epsilon tensors is still there no matter which abstraction you use to sweep it under the rug...

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

#175
post #155
post #141

Earlier quoted context omitted.

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

you're greatly overestimating how much the compiler can optimize code.

You need to be a pretty good assembler programmer in order to beat the optimizer already. Maybe in the future, with the help of "AI" the computer can do what we want, instead of what we tell it.

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

#176
post #175
post #155

Earlier quoted context omitted.

you're greatly overestimating how much the compiler can optimize code.

You need to be a pretty good assembler programmer in order to beat the optimizer already. Maybe in the future, with the help of "AI" the computer can do what we want , instead of what we tell it.

If you call .sort() which implements bogo-sort, any programmar will be able to write a better sorting algorithm in assembly. I doubt any "AI" will be able to restructure your high-level bogo-sort into an efficient algorithm.

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

#177
post #175
post #155

Earlier quoted context omitted.

you're greatly overestimating how much the compiler can optimize code.

You need to be a pretty good assembler programmer in order to beat the optimizer already. Maybe in the future, with the help of "AI" the computer can do what we want , instead of what we tell it.

I'm not especially good assembly programmer but I beat the optimizer every day, in some cases by an order of magnitude. Even best compilers suck at automatic vectorization.

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

#178
post #53

Earlier quoted context omitted.

It's very cool that the geometric product of any orthonormal basis for R^2 gives i as a "pseudoscalar". Let {e1,e2} be an orthonormal basis for R^2. Let i = e1e2. Then i^2 = e1e2e1e2 = -e1e1e2e2 (anticommutivity) = -(1)(1) = -1. Personally that alone is enough to justify learning more about geometric algebra.

That is true of the wedge product also, though. That's my point. The geometric product gives very little power over the wedge product, and when it does, it's massively non-intuitive how it works.

One reason the geometric product is attractive over usual vector notation is for the same reason the usual vector notation is attractive over coordinate notations (think Maxwell Equations in terms of Ex, Ey, Ez etc [0]): instead of a verbose and highly repetitive system of equations with easy operators you can reason and calculate with a single equation, but where the operators have higher complexity, but also correspondingly more properties to exploit assuming you take the time to get familiarized with them. An example and another reason is that contary to the inner product and exterior product, the geometric product is associative, which is clearly useful!

The student who is being advised to learn integrals might similarily protest that "everything people love about integrals, could much more easily be understood by just the desirable parts: limits, of summations, of products. It is unnecessary overkill to learn the theory of integrals like int(f(x), x=a..b)+int(f(x),x=b..c)=int(f(x),x=a..c)". So yes to prove the theory of integrals you will need to understand limits, sums, products, .. but the resulting properties like the identity above are undeniably invaluable ...

Imagine being a student in an alternate history, where integrals were never defined, of course they can still derive all the results (minus the results stating things about integrals themselves) which we arrive at through our current application of integrals by means of limits of sums of products. But then every derivation that in our world would sanely use integrals would be a long verbose derivation, which they might call "limited totalizations" without reifying this concept. So they are basically rederiving the same result over and over. That's when people normally add syntactic sugar to avoid repitition. Now imagine being this student following such a course, and further imagine that before following this course you had always been somewhat of an autodidact in high school etc, so half the time you are reading your course notes and half the time you are reading books out of curriculum. One day you stumble on some "integer math" book, and then while reading you realize this is not about integers, so you reread the title and it actually reads "math of integrals". After reading on you realize that all the verbose and highly redundant notation in "limited totalization" class can be avoided. Thats what I experienced: I was reading random books about "algebraic geometry" and one of them was totally whacky and off and not algebraic geometry, then I notice the title is actually "geometric algebra". I was in my 3rd year physics. So the people who are paid to teach me are giving me shitty calculitis, most of them are simply unaware of this field, some of them are but are daunted or simply lack the time to go back through all the knowledge they have learnt and rephrase them into this language, and even if they could, it would require the whole curriculum to change in "sync" (well, with a delay of one year per generation...). It really is inertia. The number of people who have come to understand and use geometric algebra are simply fewer than the number who have come to understand and use normal linear algebra, hence there are more books on normal linear algebra. Just like the number of people who have learnt to read and write is larger than the number of people who understand linear algebra, and hence there are more fiction books, magazines...

However I believe the situation is slowly changing in the right direction, computer science didn't have compilers either for a while, sooner or later people get bored of spaghetti code...

[0] A funny anecdote is that Maxwell -the king of unification in physics- was forced by his publisher to dumb down to this coordinate notation. His original submission used Hamilton quaternions, which had also been recognized by Clifford, who had based his work off of Grassman's "geometric algebra". Clifford called the algebra "geometric algebra", but readers of Clifford started calling the subject of Clifford's work "Clifford algebra". Or something like that, I don't pedantically check history claims...

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

#179

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…

Indeed. And certainly since rotation matrices and quaternions are both representations of rotation, they should have a log that is isomorphic.

Wilder still is the log of a 4x4 transformation matrix has the same tangent-vector properties, giving a coordinate-system-invariant rotation and translation.

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

#180

Earlier quoted context omitted.

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

I think it is a good idea because both components contain useful complementary information (the cosine/sine of the angle and the plane they form), and the algebra corresponds to geometric operations.

Having an algebra that corresponds to geometric operations is good because you get a high-level framework for how to manipulate quantities instead of having to do things case by case.

Post reply on HN